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

Function test_link_resolve

testing/test_link_resolve.py:51–80  ·  view source on GitHub ↗

See: https://github.com/pytest-dev/pytest/issues/5965.

(pytester: Pytester)

Source from the content-addressed store, hash-verified

49
50
51def test_link_resolve(pytester: Pytester) -> None:
52 """See: https://github.com/pytest-dev/pytest/issues/5965."""
53 sub1 = pytester.mkpydir("sub1")
54 p = sub1.joinpath("test_foo.py")
55 p.write_text(
56 textwrap.dedent(
57 """
58 import pytest
59 def test_foo():
60 raise AssertionError()
61 """
62 )
63 )
64
65 subst = subst_path_linux
66 if sys.platform == "win32":
67 subst = subst_path_windows
68
69 with subst(p) as subst_p:
70 result = pytester.runpytest(str(subst_p), "-v")
71 # i.e.: Make sure that the error is reported as a relative path, not as a
72 # resolved path.
73 # See: https://github.com/pytest-dev/pytest/issues/5965
74 stdout = result.stdout.str()
75 assert "sub1/test_foo.py" not in stdout
76
77 # i.e.: Expect drive on windows because we just have drive:filename, whereas
78 # we expect a relative path on Linux.
79 expect = f"*{subst_p}*" if sys.platform == "win32" else "*sub2/test_foo.py*"
80 result.stdout.fnmatch_lines([expect])

Callers

nothing calls this directly

Calls 4

strMethod · 0.80
fnmatch_linesMethod · 0.80
mkpydirMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected