@@ -62,62 +62,46 @@ def basedir(
62
62
def test_basic_init (self , basedir : Path ) -> None :
63
63
conftest = PytestPluginManager ()
64
64
p = basedir / "adir"
65
- assert (
66
- conftest ._rget_with_confmod ("a" , p , importmode = "prepend" , rootpath = basedir )[
67
- 1
68
- ]
69
- == 1
70
- )
65
+ conftest ._loadconftestmodules (p , importmode = "prepend" , rootpath = basedir )
66
+ assert conftest ._rget_with_confmod ("a" , p )[1 ] == 1
71
67
72
68
def test_immediate_initialiation_and_incremental_are_the_same (
73
69
self , basedir : Path
74
70
) -> None :
75
71
conftest = PytestPluginManager ()
76
72
assert not len (conftest ._dirpath2confmods )
77
- conftest ._getconftestmodules (
78
- basedir , importmode = "prepend" , rootpath = Path (basedir )
79
- )
73
+ conftest ._loadconftestmodules (basedir , importmode = "prepend" , rootpath = basedir )
80
74
snap1 = len (conftest ._dirpath2confmods )
81
75
assert snap1 == 1
82
- conftest ._getconftestmodules (
76
+ conftest ._loadconftestmodules (
83
77
basedir / "adir" , importmode = "prepend" , rootpath = basedir
84
78
)
85
79
assert len (conftest ._dirpath2confmods ) == snap1 + 1
86
- conftest ._getconftestmodules (
80
+ conftest ._loadconftestmodules (
87
81
basedir / "b" , importmode = "prepend" , rootpath = basedir
88
82
)
89
83
assert len (conftest ._dirpath2confmods ) == snap1 + 2
90
84
91
85
def test_value_access_not_existing (self , basedir : Path ) -> None :
92
86
conftest = ConftestWithSetinitial (basedir )
93
87
with pytest .raises (KeyError ):
94
- conftest ._rget_with_confmod (
95
- "a" , basedir , importmode = "prepend" , rootpath = Path (basedir )
96
- )
88
+ conftest ._rget_with_confmod ("a" , basedir )
97
89
98
90
def test_value_access_by_path (self , basedir : Path ) -> None :
99
91
conftest = ConftestWithSetinitial (basedir )
100
92
adir = basedir / "adir"
101
- assert (
102
- conftest ._rget_with_confmod (
103
- "a" , adir , importmode = "prepend" , rootpath = basedir
104
- )[1 ]
105
- == 1
106
- )
107
- assert (
108
- conftest ._rget_with_confmod (
109
- "a" , adir / "b" , importmode = "prepend" , rootpath = basedir
110
- )[1 ]
111
- == 1.5
93
+ conftest ._loadconftestmodules (adir , importmode = "prepend" , rootpath = basedir )
94
+ assert conftest ._rget_with_confmod ("a" , adir )[1 ] == 1
95
+ conftest ._loadconftestmodules (
96
+ adir / "b" , importmode = "prepend" , rootpath = basedir
112
97
)
98
+ assert conftest ._rget_with_confmod ("a" , adir / "b" )[1 ] == 1.5
113
99
114
100
def test_value_access_with_confmod (self , basedir : Path ) -> None :
115
101
startdir = basedir / "adir" / "b"
116
102
startdir .joinpath ("xx" ).mkdir ()
117
103
conftest = ConftestWithSetinitial (startdir )
118
- mod , value = conftest ._rget_with_confmod (
119
- "a" , startdir , importmode = "prepend" , rootpath = Path (basedir )
120
- )
104
+ mod , value = conftest ._rget_with_confmod ("a" , startdir )
121
105
assert value == 1.5
122
106
assert mod .__file__ is not None
123
107
path = Path (mod .__file__ )
@@ -143,9 +127,7 @@ def test_doubledash_considered(pytester: Pytester) -> None:
143
127
conf .joinpath ("conftest.py" ).touch ()
144
128
conftest = PytestPluginManager ()
145
129
conftest_setinitial (conftest , [conf .name , conf .name ])
146
- values = conftest ._getconftestmodules (
147
- conf , importmode = "prepend" , rootpath = pytester .path
148
- )
130
+ values = conftest ._getconftestmodules (conf )
149
131
assert len (values ) == 1
150
132
151
133
@@ -192,26 +174,22 @@ def test_conftestcutdir(pytester: Pytester) -> None:
192
174
p = pytester .mkdir ("x" )
193
175
conftest = PytestPluginManager ()
194
176
conftest_setinitial (conftest , [pytester .path ], confcutdir = p )
195
- values = conftest ._getconftestmodules (
196
- p , importmode = "prepend" , rootpath = pytester .path
197
- )
177
+ conftest ._loadconftestmodules (p , importmode = "prepend" , rootpath = pytester .path )
178
+ values = conftest ._getconftestmodules (p )
198
179
assert len (values ) == 0
199
- values = conftest ._getconftestmodules (
180
+ conftest ._loadconftestmodules (
200
181
conf .parent , importmode = "prepend" , rootpath = pytester .path
201
182
)
183
+ values = conftest ._getconftestmodules (conf .parent )
202
184
assert len (values ) == 0
203
185
assert not conftest .has_plugin (str (conf ))
204
186
# but we can still import a conftest directly
205
187
conftest ._importconftest (conf , importmode = "prepend" , rootpath = pytester .path )
206
- values = conftest ._getconftestmodules (
207
- conf .parent , importmode = "prepend" , rootpath = pytester .path
208
- )
188
+ values = conftest ._getconftestmodules (conf .parent )
209
189
assert values [0 ].__file__ is not None
210
190
assert values [0 ].__file__ .startswith (str (conf ))
211
191
# and all sub paths get updated properly
212
- values = conftest ._getconftestmodules (
213
- p , importmode = "prepend" , rootpath = pytester .path
214
- )
192
+ values = conftest ._getconftestmodules (p )
215
193
assert len (values ) == 1
216
194
assert values [0 ].__file__ is not None
217
195
assert values [0 ].__file__ .startswith (str (conf ))
@@ -221,9 +199,7 @@ def test_conftestcutdir_inplace_considered(pytester: Pytester) -> None:
221
199
conf = pytester .makeconftest ("" )
222
200
conftest = PytestPluginManager ()
223
201
conftest_setinitial (conftest , [conf .parent ], confcutdir = conf .parent )
224
- values = conftest ._getconftestmodules (
225
- conf .parent , importmode = "prepend" , rootpath = pytester .path
226
- )
202
+ values = conftest ._getconftestmodules (conf .parent )
227
203
assert len (values ) == 1
228
204
assert values [0 ].__file__ is not None
229
205
assert values [0 ].__file__ .startswith (str (conf ))
@@ -433,10 +409,8 @@ def impct(p, importmode, root):
433
409
conftest = PytestPluginManager ()
434
410
conftest ._confcutdir = pytester .path
435
411
monkeypatch .setattr (conftest , "_importconftest" , impct )
436
- mods = cast (
437
- List [Path ],
438
- conftest ._getconftestmodules (sub , importmode = "prepend" , rootpath = pytester .path ),
439
- )
412
+ conftest ._loadconftestmodules (sub , importmode = "prepend" , rootpath = pytester .path )
413
+ mods = cast (List [Path ], conftest ._getconftestmodules (sub ))
440
414
expected = [ct1 , ct2 ]
441
415
assert mods == expected
442
416
0 commit comments