
Security News
Deno 2.6 + Socket: Supply Chain Defense In Your CLI
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.
pyfakefs
Advanced tools
pyfakefs implements a fake file system that mocks the Python file system modules.
Using pyfakefs, your tests operate on a fake file system in memory without
touching the real disk. The software under test requires no modification to
work with pyfakefs.
pyfakefs creates a new empty in-memory file system at each test start, which replaces
the real filesystem during the test. Think of pyfakefs as making a per-test temporary
directory, except for an entire file system.
pyfakefs is tested with current versions of Linux, Windows and macOS.
There are several ways to invoke pyfakefs:
fs fixture with pytestfake_filesystem_unittest.TestCase for unittestfake_filesystem_unittest.Patcher as context managerfake_filesystem_unittest.patchfs decorator on a single testRefer to the usage documentation for more information.
Apart from automatically mocking most file-system functions, pyfakefs provides some additional features:
pyfakefs will not work with Python libraries that use C libraries to access the file system. This is because pyfakefs cannot patch the underlying C libraries' file access functions--the C libraries will always access the real file system. Refer to the documentation for more information about the limitations of pyfakefs.
pyfakefs.py was initially developed at Google by Mike Bland as a modest fake implementation of core Python modules. It was introduced to all of Google in September 2006. At last count, pyfakefs was used in over 20,000 Python tests at Google.
Google released pyfakefs to the public in 2011 as a Google Code project.
Support for unittest and doctest was added in a fork by user jmcgeheeiv,
further corrections were made in a separate fork with user shiffdane, and after
the shutdown of Google Code
was announced, John McGehee merged all three Google Code projects together
here on GitHub. In 2022, the repository has been transferred to
pytest-dev to ensure continuous maintenance.
FAQs
Implements a fake file system that mocks the Python file system modules.
We found that pyfakefs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.