I'm writing some test cases and I want to create a temporary csv file and remove it after the test completes. For some reason, the file persists.
I was under the impression that the file only exists for the duration of the with scope. Also, am I able to access the file with the rows I have just written within the same scope?
Here is what I have so far.
with open('test.csv', 'w') as file:
writer = csv.writer(file)
writer.writerows(row_list)
return handle_upload_file(file)
My handle_upload_file just reads the data from a csv file. Could it be that the function is erroring out because the file is not in the correct format causing the file to never be deleted after?