Congratulations! You learned how to avoid potential issues related to testing applications that read files from disk. By using the methods covered in the course you can get more consistent results from your tests.
In this Code Conversation you learned how to:
- Use io.StringIOto simulate a text file on disk
- Perform file operations on a io.StringIOobject
- Decide when to use io.StringIOand when to avoid it
- Understand possible alternatives
- Mock a file object using unittest.mock

SwingPy on Aug. 3, 2024
Would’ve been good to have some benchmarking showing how StringIO is faster than reading the file. Also, I understand that the functions are both simple enough, but I think a bit of a refactoring was in order as
upcase_file_content_from_pathhas “duplicated code” fromupcase_file_content