MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_conftestcutdir

Function test_conftestcutdir

testing/test_conftest.py:181–206  ·  view source on GitHub ↗
(pytester: Pytester)

Source from the content-addressed store, hash-verified

179
180
181def test_conftestcutdir(pytester: Pytester) -> None:
182 conf = pytester.makeconftest("")
183 p = pytester.mkdir("x")
184 conftest = PytestPluginManager()
185 conftest_setinitial(conftest, [pytester.path], confcutdir=p)
186 values = conftest._getconftestmodules(
187 p, importmode="prepend", rootpath=pytester.path
188 )
189 assert len(values) == 0
190 values = conftest._getconftestmodules(
191 conf.parent, importmode="prepend", rootpath=pytester.path
192 )
193 assert len(values) == 0
194 assert Path(conf) not in conftest._conftestpath2mod
195 # but we can still import a conftest directly
196 conftest._importconftest(conf, importmode="prepend", rootpath=pytester.path)
197 values = conftest._getconftestmodules(
198 conf.parent, importmode="prepend", rootpath=pytester.path
199 )
200 assert values[0].__file__.startswith(str(conf))
201 # and all sub paths get updated properly
202 values = conftest._getconftestmodules(
203 p, importmode="prepend", rootpath=pytester.path
204 )
205 assert len(values) == 1
206 assert values[0].__file__.startswith(str(conf))
207
208
209def test_conftestcutdir_inplace_considered(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 6

_getconftestmodulesMethod · 0.95
_importconftestMethod · 0.95
PytestPluginManagerClass · 0.90
conftest_setinitialFunction · 0.85
makeconftestMethod · 0.45
mkdirMethod · 0.45

Tested by

no test coverage detected