Merge pull request #2610 from AgriConnect/doctest-lineno
Report lineno from doctest
This commit is contained in:
commit
70d9f8638f
|
@ -140,7 +140,7 @@ class DoctestItem(pytest.Item):
|
||||||
return super(DoctestItem, self).repr_failure(excinfo)
|
return super(DoctestItem, self).repr_failure(excinfo)
|
||||||
|
|
||||||
def reportinfo(self):
|
def reportinfo(self):
|
||||||
return self.fspath, None, "[doctest] %s" % self.name
|
return self.fspath, self.dtest.lineno, "[doctest] %s" % self.name
|
||||||
|
|
||||||
|
|
||||||
def _get_flag_lookup():
|
def _get_flag_lookup():
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
doctests line numbers are now reported correctly, fixing `pytest-sugar#122 <https://github.com/Frozenball/pytest-sugar/issues/122>`_.
|
|
@ -545,6 +545,22 @@ class TestDoctests(object):
|
||||||
result = testdir.runpytest(p, '--doctest-modules')
|
result = testdir.runpytest(p, '--doctest-modules')
|
||||||
result.stdout.fnmatch_lines(['* 1 passed *'])
|
result.stdout.fnmatch_lines(['* 1 passed *'])
|
||||||
|
|
||||||
|
def test_reportinfo(self, testdir):
|
||||||
|
'''
|
||||||
|
Test case to make sure that DoctestItem.reportinfo() returns lineno.
|
||||||
|
'''
|
||||||
|
p = testdir.makepyfile(test_reportinfo="""
|
||||||
|
def foo(x):
|
||||||
|
'''
|
||||||
|
>>> foo('a')
|
||||||
|
'b'
|
||||||
|
'''
|
||||||
|
return 'c'
|
||||||
|
""")
|
||||||
|
items, reprec = testdir.inline_genitems(p, '--doctest-modules')
|
||||||
|
reportinfo = items[0].reportinfo()
|
||||||
|
assert reportinfo[1] == 1
|
||||||
|
|
||||||
|
|
||||||
class TestLiterals(object):
|
class TestLiterals(object):
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue