1 new commit in pytest:

https://bitbucket.org/hpk42/pytest/changeset/f295bff17f6e/
changeset:   f295bff17f6e
user:        hpk42
date:        2011-11-15 14:28:22
summary:     fix issue89 apply Daniel Nouri's patch to doctest/--pdb 
interaction.
affected #:  5 files

diff -r 9f8512dc3ee8f76491d39f3283642e4833c6e99c -r 
f295bff17f6efdeb00799132bf378b7ec4af8452 AUTHORS
--- a/AUTHORS
+++ b/AUTHORS
@@ -22,3 +22,4 @@
 Grig Gheorghiu
 Bob Ippolito
 Christian Tismer
+Daniel Nuri


diff -r 9f8512dc3ee8f76491d39f3283642e4833c6e99c -r 
f295bff17f6efdeb00799132bf378b7ec4af8452 CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -14,6 +14,7 @@
 - new feature to help optimizing the speed of your tests: 
   --durations=N option for displaying N slowest test calls 
   and setup/teardown methods.
+- fix issue89: --pdb with unexpected exceptions in doctest work more sensibly
 - fix and cleanup pytest's own test suite to not leak FDs 
 - fix issue83: link to generated funcarg list
 - fix issue74: pyarg module names are now checked against imp.find_module 
false positives


diff -r 9f8512dc3ee8f76491d39f3283642e4833c6e99c -r 
f295bff17f6efdeb00799132bf378b7ec4af8452 _pytest/pdb.py
--- a/_pytest/pdb.py
+++ b/_pytest/pdb.py
@@ -70,7 +70,13 @@
         tw.sep(">", "traceback")
         rep.toterminal(tw)
         tw.sep(">", "entering PDB")
-        post_mortem(call.excinfo._excinfo[2])
+        # A doctest.UnexpectedException is not useful for post_mortem.
+        # Use the underlying exception instead:
+        if isinstance(call.excinfo.value, py.std.doctest.UnexpectedException):
+            tb = call.excinfo.value.exc_info[2]
+        else:
+            tb = call.excinfo._excinfo[2]
+        post_mortem(tb)
         rep._pdbshown = True
         return rep
 


diff -r 9f8512dc3ee8f76491d39f3283642e4833c6e99c -r 
f295bff17f6efdeb00799132bf378b7ec4af8452 doc/announce/release-2.2.0.txt
--- a/doc/announce/release-2.2.0.txt
+++ b/doc/announce/release-2.2.0.txt
@@ -40,7 +40,7 @@
   most code probably "just" works because the hook was already called
   for failing setup/teardown phases of a test.
 
-Thanks to Ronny Pfannschmidt, David Burns, Jeff Donner XXX for their
+Thanks to Ronny Pfannschmidt, David Burns, Jeff Donner, Daniel Nouri, XXX for 
their
 help and feedback on various issues.
 
 best,


diff -r 9f8512dc3ee8f76491d39f3283642e4833c6e99c -r 
f295bff17f6efdeb00799132bf378b7ec4af8452 testing/test_pdb.py
--- a/testing/test_pdb.py
+++ b/testing/test_pdb.py
@@ -106,6 +106,26 @@
         if child.isalive():
             child.wait()
 
+    def test_pdb_interaction_doctest(self, testdir):
+        p1 = testdir.makepyfile("""
+            import pytest
+            def function_1():
+                '''
+                >>> i = 0
+                >>> assert i == 1
+                '''
+        """)
+        child = testdir.spawn_pytest("--doctest-modules --pdb %s" % p1)
+        child.expect("(Pdb)")
+        child.sendline('i')
+        child.expect("0")
+        child.expect("(Pdb)")
+        child.sendeof()
+        rest = child.read()
+        assert "1 failed" in rest
+        if child.isalive():
+            child.wait()
+
     def test_pdb_interaction_capturing_twice(self, testdir):
         p1 = testdir.makepyfile("""
             import pytest

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.
_______________________________________________
py-svn mailing list
py-svn@codespeak.net
http://codespeak.net/mailman/listinfo/py-svn

Reply via email to