I have a long series of unit tests that I am trying to parse into a text file, and while I know this can be accomplished with a few different uses of calling unittest.main(), I'm having a bit of a hiccup because the code I am working on needs to use a function. It is currently written as
unittest.TextTestRunner(verbosity=2).run(customFunction())
of which the stdout is read by another file with
p = Popen(command, stdout=PIPE, stderr=STDOUT stdin=PIPE)
result = p.communicate()
# Write result to .txt file
The only issue with this is that the program hangs when assigning the result variable to the console output due to some other programs the unit tests have to call. I'm trying to rewrite the code to have the unit test itself spit out into a log file (as opposed to parsing the console output into a text file), but I'm running into some hiccups in rewritting this using unittest.main() due to the custom function that has to be provided. Does anyone have any advice or solutions on how to go about doing this?