File tree Expand file tree Collapse file tree 5 files changed +66
-2
lines changed Expand file tree Collapse file tree 5 files changed +66
-2
lines changed Original file line number Diff line number Diff line change @@ -134,6 +134,7 @@ jobs:
134134 run : |
135135 echo "$(python -m pytest pyfakefs/pytest_tests/pytest_plugin_failing_helper.py)" > ./testresult.txt
136136 pytest pyfakefs/pytest_tests
137+ pytest pyfakefs/pytest_session_tests
137138 cd pyfakefs/pytest_tests/ns_package
138139 pytest --log-cli-level=INFO test
139140 shell : bash
Original file line number Diff line number Diff line change @@ -25,7 +25,9 @@ The released versions correspond to PyPI releases.
2525* fixed a regression that could break tests under Posix in Python 3.12
2626 (see [#1126](../../issues/1126))
2727* fixed behavior for `os.access` for symlinks under Windows
28- * fixes permission problem on querying file properties (see [#1122](../../issues/1122))
28+ * fixed permission problem on querying file properties (see [#1122](../../issues/1122))
29+ * fixed patching in pytest setup phase for module and session-scoped fs fixtures
30+ (see [#1126](../../issues/1126))
2931
3032### Documentation
3133* use a theme for documentation supporting dark mode
Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ def pytest_runtest_logreport(report):
9292
9393
9494@pytest .hookimpl (hookwrapper = True , trylast = True )
95- def pytest_runtest_call (item ):
95+ def pytest_runtest_setup (item ):
9696 if Patcher .PATCHER is not None :
9797 Patcher .PATCHER .resume ()
9898 yield
Original file line number Diff line number Diff line change 1+ from pathlib import Path
2+
3+ import pytest
4+
5+ from pyfakefs .fake_filesystem import FakeFilesystem
6+
7+
8+ def pytest_generate_tests (metafunc ):
9+ handlers = [a , b , c ]
10+ if "handler_class" in metafunc .fixturenames :
11+ metafunc .parametrize ("handler_class" , handlers )
12+
13+
14+ def a ():
15+ pass
16+
17+
18+ def b ():
19+ pass
20+
21+
22+ def c ():
23+ pass
24+
25+
26+ @pytest .fixture
27+ def class_a ():
28+ pass
29+
30+
31+ @pytest .fixture
32+ def class_b ():
33+ pass
34+
35+
36+ @pytest .fixture
37+ def class_c ():
38+ pass
39+
40+
41+ @pytest .fixture
42+ def make_handler (request ):
43+ def _make_handler (cls ):
44+ return request .getfixturevalue (f"class_{ cls .__name__ } " )
45+
46+ yield _make_handler
47+
48+
49+ @pytest .fixture
50+ def handler_and_check (handler_class , make_handler ):
51+ assert Path ("/foo/bar" ).exists ()
52+ yield
53+
54+
55+ def test_handler_and_check_in_fixture (handler_and_check ):
56+ assert Path ("/foo/bar" ).exists ()
57+
58+
59+ @pytest .fixture (scope = "session" , autouse = True )
60+ def config (fs_session : FakeFilesystem ):
61+ fs_session .create_file ("/foo/bar" )
You can’t perform that action at this time.
0 commit comments