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

Method test_testpaths_ini

testing/test_collection.py:243–271  ·  view source on GitHub ↗
(self, pytester: Pytester, monkeypatch: MonkeyPatch)

Source from the content-addressed store, hash-verified

241 rec.assertoutcome(failed=1)
242
243 def test_testpaths_ini(self, pytester: Pytester, monkeypatch: MonkeyPatch) -> None:
244 pytester.makeini(
245 """
246 [pytest]
247 testpaths = gui uts
248 """
249 )
250 tmp_path = pytester.path
251 ensure_file(tmp_path / "env" / "test_1.py").write_text("def test_env(): pass")
252 ensure_file(tmp_path / "gui" / "test_2.py").write_text("def test_gui(): pass")
253 ensure_file(tmp_path / "uts" / "test_3.py").write_text("def test_uts(): pass")
254
255 # executing from rootdir only tests from `testpaths` directories
256 # are collected
257 items, reprec = pytester.inline_genitems("-v")
258 assert [x.name for x in items] == ["test_gui", "test_uts"]
259
260 # check that explicitly passing directories in the command-line
261 # collects the tests
262 for dirname in ("env", "gui", "uts"):
263 items, reprec = pytester.inline_genitems(tmp_path.joinpath(dirname))
264 assert [x.name for x in items] == ["test_%s" % dirname]
265
266 # changing cwd to each subdirectory and running pytest without
267 # arguments collects the tests in that directory normally
268 for dirname in ("env", "gui", "uts"):
269 monkeypatch.chdir(pytester.path.joinpath(dirname))
270 items, reprec = pytester.inline_genitems()
271 assert [x.name for x in items] == ["test_%s" % dirname]
272
273
274class TestCollectPluginHookRelay:

Callers

nothing calls this directly

Calls 4

ensure_fileFunction · 0.85
makeiniMethod · 0.45
inline_genitemsMethod · 0.45
chdirMethod · 0.45

Tested by

no test coverage detected