@@ -87,18 +87,49 @@ Limitations
8787
8888- ``pyfakefs `` may not work correctly if file system functions are patched by
8989 other means (e.g. using `unittest.mock.patch `) - see
90- :ref: `usage_with_mock_open ` for more information
90+ :ref: `usage_with_mock_open ` for more information.
9191
9292- ``pyfakefs `` will not work correctly with
9393 `behave <https://github.com/behave/behave >`__ due to the way it loads
9494 the steps, if any filesystem modules are imported globally in the steps or
9595 environment files; as a workaround, you may load them locally inside the
96- test steps (see `this issue <https://github.com/pytest-dev/pyfakefs/issues/703 >`__)
96+ test steps (see `this issue <https://github.com/pytest-dev/pyfakefs/issues/703 >`__).
9797
9898- ``pyfakefs `` is not guaranteed to work correctly in multi-threading environments.
9999 Specifically, it does not ensure concurrent write access to a file from different
100100 threads, which is possible under Posix.
101101
102+
103+ .. |br | raw :: html
104+
105+ <br />
106+
107+ Alternatives
108+ ------------
109+ Given the above limitations, it is not always possible to use `pyfakefs ` to emulate the
110+ filesystem. There are other possibilities to test the filesystem that you may consider
111+ instead, for example:
112+
113+ - Use temporary files in the temp directory of your OS. |br |
114+ *Pros *: Is is relatively easy to setup new tests, and the temp files are not affecting the
115+ functionality of the actual file system. Under POSIX systems, they are also cleaned up
116+ periodically. |br |
117+ *Cons *: It is slower because the actual disk is used, cleaning up after tests can be
118+ a problem, and the filesystem lives in a fixed location, which cannot always be used
119+ in the tested code.
120+
121+ - Use a RAM disk. |br |
122+ *Pros *: It is memory-based and therefore fast, and can be set up to a clean state before
123+ each test. |br |
124+ *Cons *: The filesystem lives in a fixed location, which cannot always be used in the tested code.
125+
126+ - Use a filesystem abstraction like `PyFilesystem <https://github.com/PyFilesystem/pyfilesystem2/ >`__. |br |
127+ *Pros *: You can replace the real filesystem by a memory based filesystem in your tests,
128+ which has the same advantages as using ``pyfakefs ``. |br |
129+ *Cons *: Your production code must use this abstraction, so this is more a consideration
130+ for new projects.
131+
132+
102133History
103134-------
104135``pyfakefs `` was initially developed at Google by
0 commit comments