From 869eed9898df0d06c7d9be916d4224141c7dd3fe Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Tue, 4 Jul 2017 12:57:15 +0200 Subject: [PATCH] Fix lineno offset in show_skipped The line number is 0-based here, so add 1. --- _pytest/skipping.py | 2 +- changelog/2548.bugfix | 1 + testing/test_skipping.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 changelog/2548.bugfix 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