See: https://github.com/pytest-dev/pytest/issues/5965.
(pytester: Pytester)
| 49 | |
| 50 | |
| 51 | def 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]) |
nothing calls this directly
no test coverage detected