pyfakefs: Create Fake File System in Memory for Testing

Sometimes you might want to test if the function that interacts with files is working properly but don’t want the tests to touch the real disk.

pyfakefs allows your tests to operate on a file system in memory without touching the real disk.

In the code above, I created a fake directory and tested if create_file is creating a new file in the fake directory.

Scroll to Top

Work with Khuyen Tran

Work with Khuyen Tran