MCPcopy
hub / github.com/pytest-dev/pytest / test_conftestcutdir

Function test_conftestcutdir

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

Source from the content-addressed store, hash-verified

200
201
202def test_conftestcutdir(pytester: Pytester) -> None:
203 conf = pytester.makeconftest("")
204 p = pytester.mkdir("x")
205 conftest = PytestPluginManager()
206 conftest_setinitial(conftest, [pytester.path], confcutdir=p)
207 conftest._loadconftestmodules(
208 p,
209 importmode="prepend",
210 rootpath=pytester.path,
211 consider_namespace_packages=False,
212 )
213 values = conftest._getconftestmodules(p)
214 assert len(values) == 0
215 conftest._loadconftestmodules(
216 conf.parent,
217 importmode="prepend",
218 rootpath=pytester.path,
219 consider_namespace_packages=False,
220 )
221 values = conftest._getconftestmodules(conf.parent)
222 assert len(values) == 0
223 assert not conftest.has_plugin(str(conf))
224 # but we can still import a conftest directly
225 conftest._importconftest(
226 conf,
227 importmode="prepend",
228 rootpath=pytester.path,
229 consider_namespace_packages=False,
230 )
231 values = conftest._getconftestmodules(conf.parent)
232 assert values[0].__file__ is not None
233 assert values[0].__file__.startswith(str(conf))
234 # and all sub paths get updated properly
235 values = conftest._getconftestmodules(p)
236 assert len(values) == 1
237 assert values[0].__file__ is not None
238 assert values[0].__file__.startswith(str(conf))
239
240
241def test_conftestcutdir_inplace_considered(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 8

_loadconftestmodulesMethod · 0.95
_getconftestmodulesMethod · 0.95
_importconftestMethod · 0.95
PytestPluginManagerClass · 0.90
conftest_setinitialFunction · 0.85
has_pluginMethod · 0.80
makeconftestMethod · 0.45
mkdirMethod · 0.45

Tested by

no test coverage detected