[py-svn] r37257 - in py/branch/config/py: code test test/rsession
fijal at codespeak.net
fijal at codespeak.net
Wed Jan 24 13:54:31 CET 2007
Author: fijal
Date: Wed Jan 24 13:54:30 2007
New Revision: 37257
Modified:
py/branch/config/py/code/traceback2.py
py/branch/config/py/test/representation.py
py/branch/config/py/test/rsession/outcome.py
Log:
Yeah, but it seems that short tracebacks was not tested at all, argh argh argh.
Modified: py/branch/config/py/code/traceback2.py
==============================================================================
--- py/branch/config/py/code/traceback2.py (original)
+++ py/branch/config/py/code/traceback2.py Wed Jan 24 13:54:30 2007
@@ -82,6 +82,10 @@
line = "<could not get sourceline>"
return " File %r:%d in %s\n %s\n" %(fn, self.lineno+1, name, line)
+ def name(self):
+ return self.frame.code.raw.co_name
+ name = property(name, None, None, "co_name of underlaying code")
+
class Traceback(list):
""" Traceback objects encapsulate and offer higher level
access to Traceback entries.
Modified: py/branch/config/py/test/representation.py
==============================================================================
--- py/branch/config/py/test/representation.py (original)
+++ py/branch/config/py/test/representation.py Wed Jan 24 13:54:30 2007
@@ -138,17 +138,20 @@
last = traceback[-1]
first = traceback[0]
self.out.line()
- for index, entry in py.builtin.enumerate(traceback):
- code = entry.frame.code
+ for index, entry in py.builtin.enumerate(traceback):
+ path = entry.path.basename
+ firstsourceline = entry.getfirstlinesource()
+ relline = entry.lineno - firstsourceline
self.out.line(' File "%s", line %d, in %s' % (
- code.raw.co_filename, entry.lineno+1, code.raw.co_name))
+ path, entry.lineno+1, entry.name))
try:
- fullsource = entry.frame.code.fullsource
+ source = entry.getsource().lines
except py.error.ENOENT:
source = ["?"]
else:
try:
- source = [fullsource[entry.lineno].lstrip()]
+ if len(source) > 1:
+ source = source[relline]
except IndexError:
source = []
if entry == last:
@@ -158,7 +161,7 @@
else:
if source:
self.repr_source(source, ' ')
- self.repr_locals(entry.frame.f_locals)
+ self.repr_locals(entry.locals)
# trailing info
if entry == last:
Modified: py/branch/config/py/test/rsession/outcome.py
==============================================================================
--- py/branch/config/py/test/rsession/outcome.py (original)
+++ py/branch/config/py/test/rsession/outcome.py Wed Jan 24 13:54:30 2007
@@ -38,11 +38,12 @@
source = str(tb_entry.getsource())
else:
source = str(tb_entry.getsource()).split("\n")[relline]
+ name = tb_entry.frame.code.raw.co_name
# XXX: Bare except. What can getsource() raise anyway?
# SyntaxError, AttributeError, IndentationError for sure, check it
#except:
# source = "<could not get source>"
- return (relline, lineno, source, path)
+ return (relline, lineno, source, path, name)
def make_repr(self, tbstyle="long"):
return (self.passed, self.setupfailure,
@@ -51,8 +52,9 @@
class TracebackEntryRepr(object):
def __init__(self, tbentry):
- relline, lineno, self.source, self.path = tbentry
+ relline, lineno, self.source, self.path, self.name = tbentry
self.relline = int(relline)
+ self.path = py.path.local(self.path)
self.lineno = int(lineno)
self.locals = {}
More information about the pytest-commit
mailing list