(radomir, holger) tweak doctest reporting for docstrings from python modules
--HG-- branch : 1.0.x
This commit is contained in:
parent
d056149b67
commit
6167ba8923
|
@ -39,13 +39,13 @@ class DoctestItem(py.test.collect.Item):
|
||||||
example = doctestfailure.example
|
example = doctestfailure.example
|
||||||
test = doctestfailure.test
|
test = doctestfailure.test
|
||||||
filename = test.filename
|
filename = test.filename
|
||||||
lineno = example.lineno + 1
|
lineno = test.lineno + example.lineno + 1
|
||||||
message = excinfo.type.__name__
|
message = excinfo.type.__name__
|
||||||
reprlocation = ReprFileLocation(filename, lineno, message)
|
reprlocation = ReprFileLocation(filename, lineno, message)
|
||||||
checker = py.compat.doctest.OutputChecker()
|
checker = py.compat.doctest.OutputChecker()
|
||||||
REPORT_UDIFF = py.compat.doctest.REPORT_UDIFF
|
REPORT_UDIFF = py.compat.doctest.REPORT_UDIFF
|
||||||
filelines = py.path.local(filename).readlines(cr=0)
|
filelines = py.path.local(filename).readlines(cr=0)
|
||||||
i = max(0, lineno - 10)
|
i = max(test.lineno, max(0, lineno - 10)) # XXX?
|
||||||
lines = []
|
lines = []
|
||||||
for line in filelines[i:lineno]:
|
for line in filelines[i:lineno]:
|
||||||
lines.append("%03d %s" % (i+1, line))
|
lines.append("%03d %s" % (i+1, line))
|
||||||
|
@ -140,6 +140,28 @@ class TestDoctests:
|
||||||
reprec = testdir.inline_run(p, "--doctest-modules")
|
reprec = testdir.inline_run(p, "--doctest-modules")
|
||||||
reprec.assertoutcome(failed=1)
|
reprec.assertoutcome(failed=1)
|
||||||
|
|
||||||
|
def test_doctestmodule_external(self, testdir):
|
||||||
|
p = testdir.makepyfile("""
|
||||||
|
#
|
||||||
|
def somefunc():
|
||||||
|
'''
|
||||||
|
>>> i = 0
|
||||||
|
>>> i + 1
|
||||||
|
2
|
||||||
|
'''
|
||||||
|
""")
|
||||||
|
result = testdir.runpytest(p, "--doctest-modules")
|
||||||
|
result.stdout.fnmatch_lines([
|
||||||
|
'004 *>>> i = 0',
|
||||||
|
'005 *>>> i + 1',
|
||||||
|
'*Expected:',
|
||||||
|
"* 2",
|
||||||
|
"*Got:",
|
||||||
|
"* 1",
|
||||||
|
"*:5: DocTestFailure"
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
def test_txtfile_failing(self, testdir):
|
def test_txtfile_failing(self, testdir):
|
||||||
p = testdir.maketxtfile("""
|
p = testdir.maketxtfile("""
|
||||||
>>> i = 0
|
>>> i = 0
|
||||||
|
|
Loading…
Reference in New Issue