Merge pull request #7158 from CarycaKatarzyna/issue_7076

This commit is contained in:
Bruno Oliveira 2020-05-08 07:56:03 -03:00 committed by GitHub
commit 9657798c12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 2 deletions

View File

@ -0,0 +1 @@
The path of file skipped by ``@pytest.mark.skip`` in the SKIPPED report is now relative to invocation directory. Previously it was relative to root directory.

View File

@ -168,8 +168,8 @@ def pytest_runtest_makereport(item, call):
# to point to the item definition, otherwise it will display
# the location of where the skip exception was raised within pytest
_, _, reason = rep.longrepr
filename, line = item.location[:2]
rep.longrepr = filename, line + 1, reason
filename, line = item.reportinfo()[:2]
rep.longrepr = str(filename), line + 1, reason
# called by terminalreporter progress reporting

View File

@ -1176,3 +1176,20 @@ def test_importorskip():
match="^could not import 'doesnotexist': No module named .*",
):
pytest.importorskip("doesnotexist")
def test_relpath_rootdir(testdir):
testdir.makepyfile(
**{
"tests/test_1.py": """
import pytest
@pytest.mark.skip()
def test_pass():
pass
""",
}
)
result = testdir.runpytest("-rs", "tests/test_1.py", "--rootdir=tests")
result.stdout.fnmatch_lines(
["SKIPPED [[]1[]] tests/test_1.py:2: unconditional skip"]
)