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

Method test_cwd_changed

testing/test_assertrewrite.py:1467–1490  ·  view source on GitHub ↗
(self, pytester: Pytester, monkeypatch)

Source from the content-addressed store, hash-verified

1465 sys.platform.startswith("sunos5"), reason="cannot remove cwd on Solaris"
1466 )
1467 def test_cwd_changed(self, pytester: Pytester, monkeypatch) -> None:
1468 # Setup conditions for py's fspath trying to import pathlib on py34
1469 # always (previously triggered via xdist only).
1470 # Ref: https://github.com/pytest-dev/py/pull/207
1471 monkeypatch.syspath_prepend("")
1472 monkeypatch.delitem(sys.modules, "pathlib", raising=False)
1473
1474 pytester.makepyfile(
1475 **{
1476 "test_setup_nonexisting_cwd.py": """\
1477 import os
1478 import tempfile
1479
1480 with tempfile.TemporaryDirectory() as d:
1481 os.chdir(d)
1482 """,
1483 "test_test.py": """\
1484 def test():
1485 pass
1486 """,
1487 }
1488 )
1489 result = pytester.runpytest()
1490 result.stdout.fnmatch_lines(["* 1 passed in *"])
1491
1492
1493class TestAssertionPass:

Callers

nothing calls this directly

Calls 5

syspath_prependMethod · 0.80
delitemMethod · 0.80
fnmatch_linesMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected