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