Overview of pyfakefs features
mainpyfakefs provides a memory-based fake filesystem that mocks Python's filesystem modules. Key features include:
- Transparent Operation: Code works on the fake filesystem without modification.
- Framework Support: Direct support for
pytest(via thefsfixture) andunittest, but compatible with other frameworks. - Isolation: Each test starts with an empty filesystem (except for OS temporary directories). Real files are not modified even when mapping real files into the fake system.
- Configurability:
- Filesystem Size: Can be configured arbitrarily.
- OS Simulation: Can simulate Linux, macOS, or Windows regardless of the host OS.
- User Simulation: Can simulate running as root or a non-root user.
- Pause/Resume: Ability to temporarily use the real filesystem during a test step.