Merge pull request #9804 from nicoddemus/311-cwd-tests
This commit is contained in:
commit
250a0344ad
|
@ -651,7 +651,7 @@ class Test_getinitialnodes:
|
|||
for parent in col.listchain():
|
||||
assert parent.config is config
|
||||
|
||||
def test_pkgfile(self, pytester: Pytester) -> None:
|
||||
def test_pkgfile(self, pytester: Pytester, monkeypatch: MonkeyPatch) -> None:
|
||||
"""Verify nesting when a module is within a package.
|
||||
The parent chain should match: Module<x.py> -> Package<subdir> -> Session.
|
||||
Session's parent should always be None.
|
||||
|
@ -660,7 +660,9 @@ class Test_getinitialnodes:
|
|||
subdir = tmp_path.joinpath("subdir")
|
||||
x = ensure_file(subdir / "x.py")
|
||||
ensure_file(subdir / "__init__.py")
|
||||
config = pytester.parseconfigure(x)
|
||||
with monkeypatch.context() as mp:
|
||||
mp.chdir(subdir)
|
||||
config = pytester.parseconfigure(x)
|
||||
col = pytester.getnode(config, x)
|
||||
assert col is not None
|
||||
assert col.name == "x.py"
|
||||
|
@ -1221,7 +1223,9 @@ def test_collect_pyargs_with_testpaths(
|
|||
)
|
||||
)
|
||||
monkeypatch.setenv("PYTHONPATH", str(pytester.path), prepend=os.pathsep)
|
||||
result = pytester.runpytest_subprocess()
|
||||
with monkeypatch.context() as mp:
|
||||
mp.chdir(root)
|
||||
result = pytester.runpytest_subprocess()
|
||||
result.stdout.fnmatch_lines(["*1 passed in*"])
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue