Skip to content

Commit

Permalink
Update troubleshooting to include django info
Browse files Browse the repository at this point in the history
As discussed on #170, we expand the troubleshooting section to include some instructions for adding pyfakefs to a django project without breaking existing tests.
  • Loading branch information
jakespracher authored and mrbean-bremen committed Feb 21, 2023
1 parent b59235b commit db0d1fc
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/troubleshooting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,26 @@ from configuration files. In these cases, you have to map the respective files
or directories from the real into the fake filesystem as described in
:ref:`real_fs_access`.

If you are using Django, various dependencies may expect both the project
directory and the ``site-packages`` installation to exist in the fake filesystem.

Here's an example of how to add these using pytest::


import os
import django
import pytest

@pytest.fixture
def fake_fs(fs):
PROJECT_BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
fs.add_real_paths(
[
PROJECT_BASE_DIR,
os.path.dirname(django.__file__),
]
)
return fs

OS temporary directories
------------------------
Expand Down

0 comments on commit db0d1fc

Please sign in to comment.