[py-svn] commit/pytest: hpk42: fix issue43 - better tracebacks for unexpected exceptions in doctests
Bitbucket
commits-noreply at bitbucket.org
Sat May 28 14:38:29 CEST 2011
1 new changeset in pytest:
http://bitbucket.org/hpk42/pytest/changeset/fd6fd56eeb97/
changeset: fd6fd56eeb97
branches:
user: hpk42
date: 2011-05-28 14:38:15
summary: fix issue43 - better tracebacks for unexpected exceptions in doctests
affected #: 3 files (649 bytes)
--- a/CHANGELOG Sat May 28 14:03:10 2011 +0200
+++ b/CHANGELOG Sat May 28 14:38:15 2011 +0200
@@ -1,6 +1,8 @@
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
- introduce XXX pytest_configure_funcargs hack (thanks Ronny)
- env/username expansion for junitxml file path (fixes issue44)
--- a/_pytest/doctest.py Sat May 28 14:03:10 2011 +0200
+++ b/_pytest/doctest.py Sat May 28 14:38:15 2011 +0200
@@ -59,7 +59,7 @@
inner_excinfo = py.code.ExceptionInfo(excinfo.value.exc_info)
lines += ["UNEXPECTED EXCEPTION: %s" %
repr(inner_excinfo.value)]
-
+ lines += py.std.traceback.format_exception(*excinfo.value.exc_info)
return ReprFailDoctest(reprlocation, lines)
else:
return super(DoctestItem, self).repr_failure(excinfo)
--- a/testing/test_doctest.py Sat May 28 14:03:10 2011 +0200
+++ b/testing/test_doctest.py Sat May 28 14:38:15 2011 +0200
@@ -59,6 +59,21 @@
"*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):
p = testdir.makepyfile("""
'''
Repository URL: https://bitbucket.org/hpk42/pytest/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the pytest-commit
mailing list