Merge pull request #1806 from blueyed/fix-off-by-one-error-with-warnings
Fix off-by-one error with lines from request.node.warn
This commit is contained in:
commit
ca5957932b
|
@ -73,7 +73,8 @@
|
||||||
|
|
||||||
*
|
*
|
||||||
|
|
||||||
*
|
* Fixed off-by-one error with lines from ``request.node.warn``.
|
||||||
|
Thanks to `@blueyed`_ for the PR.
|
||||||
|
|
||||||
*
|
*
|
||||||
|
|
||||||
|
|
|
@ -267,7 +267,7 @@ class Node(object):
|
||||||
if fslocation is None:
|
if fslocation is None:
|
||||||
fslocation = getattr(self, "fspath", None)
|
fslocation = getattr(self, "fspath", None)
|
||||||
else:
|
else:
|
||||||
fslocation = "%s:%s" % fslocation[:2]
|
fslocation = "%s:%s" % (fslocation[0], fslocation[1] + 1)
|
||||||
|
|
||||||
self.ihook.pytest_logwarning.call_historic(kwargs=dict(
|
self.ihook.pytest_logwarning.call_historic(kwargs=dict(
|
||||||
code=code, message=message,
|
code=code, message=message,
|
||||||
|
|
|
@ -525,13 +525,14 @@ class TestWarning:
|
||||||
reprec = testdir.inline_run()
|
reprec = testdir.inline_run()
|
||||||
reprec.assertoutcome(passed=1)
|
reprec.assertoutcome(passed=1)
|
||||||
|
|
||||||
def test_warn_on_test_item_from_request(self, testdir):
|
def test_warn_on_test_item_from_request(self, testdir, request):
|
||||||
testdir.makepyfile("""
|
testdir.makepyfile("""
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def fix(request):
|
def fix(request):
|
||||||
request.node.warn("T1", "hello")
|
request.node.warn("T1", "hello")
|
||||||
|
|
||||||
def test_hello(fix):
|
def test_hello(fix):
|
||||||
pass
|
pass
|
||||||
""")
|
""")
|
||||||
|
@ -542,7 +543,7 @@ class TestWarning:
|
||||||
result = testdir.runpytest("-rw")
|
result = testdir.runpytest("-rw")
|
||||||
result.stdout.fnmatch_lines("""
|
result.stdout.fnmatch_lines("""
|
||||||
===*pytest-warning summary*===
|
===*pytest-warning summary*===
|
||||||
*WT1*test_warn_on_test_item*:5*hello*
|
*WT1*test_warn_on_test_item*:7 hello*
|
||||||
""")
|
""")
|
||||||
|
|
||||||
class TestRootdir:
|
class TestRootdir:
|
||||||
|
|
Loading…
Reference in New Issue