(self, pytester: Pytester, monkeypatch: MonkeyPatch)
| 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 | |
| 274 | class TestCollectPluginHookRelay: |
nothing calls this directly
no test coverage detected