I need to pass an argument that has to read a file as well as a string in the python function. Here, it works fine when I pass a filename as variable, but the elif
block doesn't work here which has to read a string. Please help
def test_save(self, test_data):
if Path(test_data).is_file():
with open(test_data, 'r') as f:
result= f.read()
elif type(test_data) is str:
result= test_data
data = {
"president": {
"details": result
}
test_data_String_value = "<note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>" }
test_save(test_data_String_value)