diff --git a/_pytest/skipping.py b/_pytest/skipping.py index 619650092..b11aea801 100644 --- a/_pytest/skipping.py +++ b/_pytest/skipping.py @@ -382,4 +382,4 @@ def show_skipped(terminalreporter, lines): reason = reason[9:] lines.append( "SKIP [%d] %s:%d: %s" % - (num, fspath, lineno, reason)) + (num, fspath, lineno + 1, reason)) diff --git a/changelog/2548.bugfix b/changelog/2548.bugfix new file mode 100644 index 000000000..9a44dc334 --- /dev/null +++ b/changelog/2548.bugfix @@ -0,0 +1 @@ +Fix lineno offset in show_skipped. diff --git a/testing/test_skipping.py b/testing/test_skipping.py index b780e4dc8..6608ccadf 100644 --- a/testing/test_skipping.py +++ b/testing/test_skipping.py @@ -708,7 +708,7 @@ def test_skipped_reasons_functional(testdir): ) result = testdir.runpytest('-rs') result.stdout.fnmatch_lines([ - "*SKIP*2*conftest.py:3: test", + "*SKIP*2*conftest.py:4: test", ]) assert result.ret == 0