13
13
from _pytest .main import EXIT_USAGEERROR
14
14
15
15
16
- @pytest .fixture (scope = "module" , params = ["global" , "inpackage" ])
17
- def basedir (request , tmpdir_factory ):
18
- tmpdir = tmpdir_factory .mktemp ("basedir" , numbered = True )
19
- tmpdir .ensure ("adir/conftest.py" ).write ("a=1 ; Directory = 3" )
20
- tmpdir .ensure ("adir/b/conftest.py" ).write ("b=2 ; a = 1.5" )
21
- if request .param == "inpackage" :
22
- tmpdir .ensure ("adir/__init__.py" )
23
- tmpdir .ensure ("adir/b/__init__.py" )
24
- return tmpdir
25
-
26
-
27
16
def ConftestWithSetinitial (path ):
28
17
conftest = PytestPluginManager ()
29
18
conftest_setinitial (conftest , [path ])
@@ -41,18 +30,30 @@ def __init__(self):
41
30
conftest ._set_initial_conftests (Namespace ())
42
31
43
32
33
+ @pytest .mark .usefixtures ("_sys_snapshot" )
44
34
class TestConftestValueAccessGlobal (object ):
35
+ @pytest .fixture (scope = "module" , params = ["global" , "inpackage" ])
36
+ def basedir (self , request , tmpdir_factory ):
37
+ tmpdir = tmpdir_factory .mktemp ("basedir" , numbered = True )
38
+ tmpdir .ensure ("adir/conftest.py" ).write ("a=1 ; Directory = 3" )
39
+ tmpdir .ensure ("adir/b/conftest.py" ).write ("b=2 ; a = 1.5" )
40
+ if request .param == "inpackage" :
41
+ tmpdir .ensure ("adir/__init__.py" )
42
+ tmpdir .ensure ("adir/b/__init__.py" )
43
+
44
+ yield tmpdir
45
+
45
46
def test_basic_init (self , basedir ):
46
47
conftest = PytestPluginManager ()
47
48
p = basedir .join ("adir" )
48
49
assert conftest ._rget_with_confmod ("a" , p )[1 ] == 1
49
50
50
51
def test_immediate_initialiation_and_incremental_are_the_same (self , basedir ):
51
52
conftest = PytestPluginManager ()
52
- len (conftest ._dirpath2confmods )
53
+ assert not len (conftest ._dirpath2confmods )
53
54
conftest ._getconftestmodules (basedir )
54
55
snap1 = len (conftest ._dirpath2confmods )
55
- # assert len(conftest._dirpath2confmods) == snap1 + 1
56
+ assert snap1 == 1
56
57
conftest ._getconftestmodules (basedir .join ("adir" ))
57
58
assert len (conftest ._dirpath2confmods ) == snap1 + 1
58
59
conftest ._getconftestmodules (basedir .join ("b" ))
@@ -80,7 +81,7 @@ def test_value_access_with_confmod(self, basedir):
80
81
assert path .purebasename .startswith ("conftest" )
81
82
82
83
83
- def test_conftest_in_nonpkg_with_init (tmpdir ):
84
+ def test_conftest_in_nonpkg_with_init (tmpdir , _sys_snapshot ):
84
85
tmpdir .ensure ("adir-1.0/conftest.py" ).write ("a=1 ; Directory = 3" )
85
86
tmpdir .ensure ("adir-1.0/b/conftest.py" ).write ("b=2 ; a = 1.5" )
86
87
tmpdir .ensure ("adir-1.0/b/__init__.py" )
0 commit comments