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

Function test_failure_with_changed_cwd

testing/test_nodes.py:140–164  ·  view source on GitHub ↗

Test failure lines should use absolute paths if cwd has changed since invocation, so the path is correct (#6428).

(pytester: Pytester)

Source from the content-addressed store, hash-verified

138
139
140def test_failure_with_changed_cwd(pytester: Pytester) -> None:
141 """
142 Test failure lines should use absolute paths if cwd has changed since
143 invocation, so the path is correct (#6428).
144 """
145 p = pytester.makepyfile(
146 """
147 import os
148 import pytest
149
150 @pytest.fixture
151 def private_dir():
152 out_dir = 'ddd'
153 os.mkdir(out_dir)
154 old_dir = os.getcwd()
155 os.chdir(out_dir)
156 yield out_dir
157 os.chdir(old_dir)
158
159 def test_show_wrong_path(private_dir):
160 assert False
161 """
162 )
163 result = pytester.runpytest()
164 result.stdout.fnmatch_lines([str(p) + ":*: AssertionError", "*1 failed in *"])

Callers

nothing calls this directly

Calls 3

fnmatch_linesMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected