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

Method test_cwd_changed

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

Source from the content-addressed store, hash-verified

1997 sys.platform.startswith("sunos5"), reason="cannot remove cwd on Solaris"
1998 )
1999 def test_cwd_changed(self, pytester: Pytester, monkeypatch) -> None:
2000 # Setup conditions for py's fspath trying to import pathlib on py34
2001 # always (previously triggered via xdist only).
2002 # Ref: https://github.com/pytest-dev/py/pull/207
2003 monkeypatch.syspath_prepend("")
2004 monkeypatch.delitem(sys.modules, "pathlib", raising=False)
2005
2006 pytester.makepyfile(
2007 **{
2008 "test_setup_nonexisting_cwd.py": """\
2009 import os
2010 import tempfile
2011
2012 with tempfile.TemporaryDirectory() as newpath:
2013 os.chdir(newpath)
2014 """,
2015 "test_test.py": """\
2016 def test():
2017 pass
2018 """,
2019 }
2020 )
2021 result = pytester.runpytest()
2022 result.stdout.fnmatch_lines(["* 1 passed in *"])
2023
2024
2025class 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