1 new commit in py:

https://bitbucket.org/hpk42/py/changeset/2366418b7ccc/
changeset:   2366418b7ccc
user:        hpk42
date:        2011-12-10 09:11:41
summary:     help to fix pytest issue99: unify output of
ExceptionInfo.getrepr(style="native") with ...(style="long")
affected #:  5 files

diff -r bb527bc1a4145d2531a0fb879aad610c04333605 -r 
2366418b7ccc912749fc7ccb759cc057c55959ca CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,8 @@
 Changes between 1.4.5 and 1.4.x
 ==================================================
 
+- help to fix pytest issue99: unify output of 
+  ExceptionInfo.getrepr(style="native") with ...(style="long")
 - fix issue7: source.getstatementrange() now raises proper error
   if no valid statement can be found
 - fix issue8: fix code and tests of svnurl/svnwc to work on subversion 1.7 - 


diff -r bb527bc1a4145d2531a0fb879aad610c04333605 -r 
2366418b7ccc912749fc7ccb759cc057c55959ca py/__init__.py
--- a/py/__init__.py
+++ b/py/__init__.py
@@ -8,7 +8,7 @@
 
 (c) Holger Krekel and others, 2004-2010
 """
-__version__ = '1.4.6.dev3'
+__version__ = '1.4.6.dev4'
 
 from py import _apipkg
 


diff -r bb527bc1a4145d2531a0fb879aad610c04333605 -r 
2366418b7ccc912749fc7ccb759cc057c55959ca py/_code/code.py
--- a/py/_code/code.py
+++ b/py/_code/code.py
@@ -283,7 +283,7 @@
         """
         cache = {}
         for i, entry in enumerate(self):
-            # id for the code.raw is needed to work around 
+            # id for the code.raw is needed to work around
             # the strange metaprogramming in the decorator lib from pypi
             # which generates code objects that have hash/value equality
             #XXX needs a test
@@ -361,14 +361,16 @@
             showlocals: show locals per traceback entry
             style: long|short|no|native traceback style
             tbfilter: hide entries (where __tracebackhide__ is true)
+
+            in case of style==native, tbfilter and showlocals is ignored.
         """
         if style == 'native':
-            import traceback
-            return ''.join(traceback.format_exception(
-                self.type,
-                self.value,
-                self.traceback[0]._rawentry,
-                ))
+            return ReprExceptionInfo(ReprTracebackNative(
+                py.std.traceback.format_exception(
+                    self.type,
+                    self.value,
+                    self.traceback[0]._rawentry,
+                )), self._getreprcrash())
 
         fmt = FormattedExcinfo(showlocals=showlocals, style=style,
             abspath=abspath, tbfilter=tbfilter, funcargs=funcargs)
@@ -612,6 +614,19 @@
         if self.extraline:
             tw.line(self.extraline)
 
+class ReprTracebackNative(ReprTraceback):
+    def __init__(self, tblines):
+        self.style = "native"
+        self.reprentries = [ReprEntryNative(tblines)]
+        self.extraline = None
+
+class ReprEntryNative(TerminalRepr):
+    def __init__(self, tblines):
+        self.lines = tblines
+
+    def toterminal(self, tw):
+        tw.write("".join(self.lines))
+
 class ReprEntry(TerminalRepr):
     localssep = "_ "
 


diff -r bb527bc1a4145d2531a0fb879aad610c04333605 -r 
2366418b7ccc912749fc7ccb759cc057c55959ca setup.py
--- a/setup.py
+++ b/setup.py
@@ -12,7 +12,7 @@
         name='py',
         description='library with cross-python path, ini-parsing, io, code, 
log facilities',
         long_description = open('README.txt').read(),
-        version='1.4.6.dev3',
+        version='1.4.6.dev4',
         url='http://pylib.org',
         license='MIT license',
         platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],


diff -r bb527bc1a4145d2531a0fb879aad610c04333605 -r 
2366418b7ccc912749fc7ccb759cc057c55959ca testing/code/test_excinfo.py
--- a/testing/code/test_excinfo.py
+++ b/testing/code/test_excinfo.py
@@ -157,7 +157,7 @@
     def test_traceback_messy_recursion(self):
         #XXX: simplified locally testable version
         decorator = py.test.importorskip('decorator').decorator
-        
+
         def log(f, *k, **kw):
             print('%s %s' % (k, kw))
             f(*k, **kw)
@@ -751,9 +751,11 @@
             assert 0
         """)
         repr = excinfo.getrepr(style='native')
-        assert repr.startswith('Traceback (most recent call last):\n  File')
-        assert repr.endswith('\nAssertionError: assert 0\n')
-        assert 'exec (source.compile())' in repr
+        assert "assert 0" in str(repr.reprcrash)
+        s = str(repr)
+        assert s.startswith('Traceback (most recent call last):\n  File')
+        assert s.endswith('\nAssertionError: assert 0')
+        assert 'exec (source.compile())' in s
         # python 2.4 fails to get the source line for the assert
         if py.std.sys.version_info >= (2, 5):
-            assert repr.count('assert 0') == 2
+            assert s.count('assert 0') == 2

Repository URL: https://bitbucket.org/hpk42/py/

--

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