Issue 4677 - always relative path in skip report (#6953)
This commit is contained in:
parent
de6c28ed1f
commit
7789b51acb
1
AUTHORS
1
AUTHORS
|
@ -148,6 +148,7 @@ Justyna Janczyszyn
|
||||||
Kale Kundert
|
Kale Kundert
|
||||||
Karl O. Pinc
|
Karl O. Pinc
|
||||||
Katarzyna Jachim
|
Katarzyna Jachim
|
||||||
|
Katarzyna Król
|
||||||
Katerina Koukiou
|
Katerina Koukiou
|
||||||
Kevin Cox
|
Kevin Cox
|
||||||
Kevin J. Foley
|
Kevin J. Foley
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
The path shown in the summary report for SKIPPED tests is now always relative. Previously it was sometimes absolute.
|
|
@ -1027,7 +1027,7 @@ class TerminalReporter:
|
||||||
|
|
||||||
def show_skipped(lines: List[str]) -> None:
|
def show_skipped(lines: List[str]) -> None:
|
||||||
skipped = self.stats.get("skipped", [])
|
skipped = self.stats.get("skipped", [])
|
||||||
fskips = _folded_skips(skipped) if skipped else []
|
fskips = _folded_skips(self.startdir, skipped) if skipped else []
|
||||||
if not fskips:
|
if not fskips:
|
||||||
return
|
return
|
||||||
verbose_word = skipped[0]._get_verbose_word(self.config)
|
verbose_word = skipped[0]._get_verbose_word(self.config)
|
||||||
|
@ -1153,11 +1153,13 @@ def _get_line_with_reprcrash_message(config, rep, termwidth):
|
||||||
return line
|
return line
|
||||||
|
|
||||||
|
|
||||||
def _folded_skips(skipped):
|
def _folded_skips(startdir, skipped):
|
||||||
d = {}
|
d = {}
|
||||||
for event in skipped:
|
for event in skipped:
|
||||||
key = event.longrepr
|
assert len(event.longrepr) == 3, (event, event.longrepr)
|
||||||
assert len(key) == 3, (event, key)
|
fspath, lineno, reason = event.longrepr
|
||||||
|
# For consistency, report all fspaths in relative form.
|
||||||
|
fspath = startdir.bestrelpath(py.path.local(fspath))
|
||||||
keywords = getattr(event, "keywords", {})
|
keywords = getattr(event, "keywords", {})
|
||||||
# folding reports with global pytestmark variable
|
# folding reports with global pytestmark variable
|
||||||
# this is workaround, because for now we cannot identify the scope of a skip marker
|
# this is workaround, because for now we cannot identify the scope of a skip marker
|
||||||
|
@ -1167,7 +1169,9 @@ def _folded_skips(skipped):
|
||||||
and "skip" in keywords
|
and "skip" in keywords
|
||||||
and "pytestmark" not in keywords
|
and "pytestmark" not in keywords
|
||||||
):
|
):
|
||||||
key = (key[0], None, key[2])
|
key = (fspath, None, reason)
|
||||||
|
else:
|
||||||
|
key = (fspath, lineno, reason)
|
||||||
d.setdefault(key, []).append(event)
|
d.setdefault(key, []).append(event)
|
||||||
values = []
|
values = []
|
||||||
for key, events in d.items():
|
for key, events in d.items():
|
||||||
|
|
|
@ -758,7 +758,7 @@ def test_skipped_reasons_functional(testdir):
|
||||||
result = testdir.runpytest("-rs")
|
result = testdir.runpytest("-rs")
|
||||||
result.stdout.fnmatch_lines_random(
|
result.stdout.fnmatch_lines_random(
|
||||||
[
|
[
|
||||||
"SKIPPED [[]2[]] */conftest.py:4: test",
|
"SKIPPED [[]2[]] conftest.py:4: test",
|
||||||
"SKIPPED [[]1[]] test_one.py:14: via_decorator",
|
"SKIPPED [[]1[]] test_one.py:14: via_decorator",
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
|
@ -2001,7 +2001,7 @@ def test_skip_reasons_folding():
|
||||||
ev3.longrepr = longrepr
|
ev3.longrepr = longrepr
|
||||||
ev3.skipped = True
|
ev3.skipped = True
|
||||||
|
|
||||||
values = _folded_skips([ev1, ev2, ev3])
|
values = _folded_skips(py.path.local(), [ev1, ev2, ev3])
|
||||||
assert len(values) == 1
|
assert len(values) == 1
|
||||||
num, fspath, lineno, reason = values[0]
|
num, fspath, lineno, reason = values[0]
|
||||||
assert num == 3
|
assert num == 3
|
||||||
|
|
Loading…
Reference in New Issue