fix issue43 - better tracebacks for unexpected exceptions in doctests
This commit is contained in:
parent
8dc4e732f0
commit
410438f187
|
@ -1,6 +1,8 @@
|
||||||
Changes between 2.0.3 and DEV
|
Changes between 2.0.3 and DEV
|
||||||
----------------------------------------------
|
----------------------------------------------
|
||||||
|
|
||||||
|
- fix issue43: improve doctests with better traceback reporting on
|
||||||
|
unexpected exceptions
|
||||||
- fix issue47: timing output in junitxml for test cases is now correct
|
- fix issue47: timing output in junitxml for test cases is now correct
|
||||||
- introduce XXX pytest_configure_funcargs hack (thanks Ronny)
|
- introduce XXX pytest_configure_funcargs hack (thanks Ronny)
|
||||||
- env/username expansion for junitxml file path (fixes issue44)
|
- env/username expansion for junitxml file path (fixes issue44)
|
||||||
|
|
|
@ -59,7 +59,7 @@ class DoctestItem(pytest.Item):
|
||||||
inner_excinfo = py.code.ExceptionInfo(excinfo.value.exc_info)
|
inner_excinfo = py.code.ExceptionInfo(excinfo.value.exc_info)
|
||||||
lines += ["UNEXPECTED EXCEPTION: %s" %
|
lines += ["UNEXPECTED EXCEPTION: %s" %
|
||||||
repr(inner_excinfo.value)]
|
repr(inner_excinfo.value)]
|
||||||
|
lines += py.std.traceback.format_exception(*excinfo.value.exc_info)
|
||||||
return ReprFailDoctest(reprlocation, lines)
|
return ReprFailDoctest(reprlocation, lines)
|
||||||
else:
|
else:
|
||||||
return super(DoctestItem, self).repr_failure(excinfo)
|
return super(DoctestItem, self).repr_failure(excinfo)
|
||||||
|
|
|
@ -59,6 +59,21 @@ class TestDoctests:
|
||||||
"*UNEXPECTED*ZeroDivision*",
|
"*UNEXPECTED*ZeroDivision*",
|
||||||
])
|
])
|
||||||
|
|
||||||
|
def test_doctest_unex_importerror(self, testdir):
|
||||||
|
testdir.tmpdir.join("hello.py").write(py.code.Source("""
|
||||||
|
import asdalsdkjaslkdjasd
|
||||||
|
"""))
|
||||||
|
p = testdir.maketxtfile("""
|
||||||
|
>>> import hello
|
||||||
|
>>>
|
||||||
|
""")
|
||||||
|
result = testdir.runpytest("--doctest-modules")
|
||||||
|
result.stdout.fnmatch_lines([
|
||||||
|
"*>>> import hello",
|
||||||
|
"*UNEXPECTED*ImportError*",
|
||||||
|
"*import asdals*",
|
||||||
|
])
|
||||||
|
|
||||||
def test_doctestmodule(self, testdir):
|
def test_doctestmodule(self, testdir):
|
||||||
p = testdir.makepyfile("""
|
p = testdir.makepyfile("""
|
||||||
'''
|
'''
|
||||||
|
|
Loading…
Reference in New Issue