[py-svn] r9646 - py/branch/py-collect/test2
hpk at codespeak.net
hpk at codespeak.net
Fri Mar 4 20:06:31 CET 2005
Author: hpk
Date: Fri Mar 4 20:06:31 2005
New Revision: 9646
Modified:
py/branch/py-collect/test2/terminal.py
Log:
more refactored reporting
Modified: py/branch/py-collect/test2/terminal.py
==============================================================================
--- py/branch/py-collect/test2/terminal.py (original)
+++ py/branch/py-collect/test2/terminal.py Fri Mar 4 20:06:31 2005
@@ -24,42 +24,53 @@
self.out.line(' ' * len(cols) + repr(colitem))
cols.append(colitem)
else:
- if isinstance(colitem, py.test2.Module):
- numunits = len(list(colitem.iteritems()))
- if numunits > 0:
- fspath = colitem.fspath
- if self.option.verbose == 0:
- parts = fspath.parts()
- basename = parts.pop().basename
- while parts and parts[-1].basename in ('testing', 'test'):
- parts.pop()
- base = parts[-1].basename
- if len(base) < 13:
- base = base + "_" * (13-len(base))
- abbrev_fn = base + "_" + basename
- self.out.write('%s[%d] ' % (abbrev_fn, numunits))
- elif self.option.verbose > 0:
- #curdir = py.path.local()
- #if fspath.check(local=True, relto=curdir):
- # fspath = fspath.relto(curdir)
- self.out.line()
- self.out.line("+ testmodule: %s" % fspath)
+ cls = getattr(colitem, '__class__', None)
+ if cls is None:
+ return
+ for typ in py.std.inspect.getmro(cls):
+ meth = getattr(self, 'start_%s' % typ.__name__, None)
+ if meth:
+ meth(colitem)
+ break
+ colitem.start = py.std.time.time()
+
+ def start_Module(self, colitem):
+ numunits = len(list(colitem.iteritems()))
+ if numunits > 0:
+ fspath = colitem.fspath
+ if self.option.verbose == 0:
+ parts = fspath.parts()
+ basename = parts.pop().basename
+ while parts and parts[-1].basename in ('testing', 'test'):
+ parts.pop()
+ base = parts[-1].basename
+ if len(base) < 13:
+ base = base + "_" * (13-len(base))
+ abbrev_fn = base + "_" + basename
+ self.out.write('%s[%d] ' % (abbrev_fn, numunits))
+ elif self.option.verbose > 0:
+ #curdir = py.path.local()
+ #if fspath.check(local=True, relto=curdir):
+ # fspath = fspath.relto(curdir)
+ self.out.line()
+ self.out.line("+ testmodule: %s" % fspath)
+
+ def start_Item(self, colitem):
if self.option.verbose >= 1:
if isinstance(colitem, py.test2.Item):
realpath, lineno = colitem.getpathlineno()
location = "%s:%d" % (realpath.basename, lineno+1)
self.out.rewrite("%-20s %s " % (
location, colitem.reprcall()))
- self._started[colitem] = now()
def finish(self, colitem, result):
end = now()
- colitem.elapsedtime = end - self._started[colitem]
if self.option.collectonly:
cols = self._opencollectors
last = cols.pop()
#assert last == colitem, "expected %r, got %r" %(last, colitem)
return
+ colitem.elapsedtime = end - colitem.start
super(TerminalDriver, self).finish(colitem, result)
if self.option.usepdb:
if isinstance(result, Item.Failed):
@@ -79,7 +90,13 @@
self.out.line()
return
else:
- self.repr_progress(colitem, result)
+ restype, c = self._processresult(result)
+ if self.option.verbose >= 1:
+ resultstring = self.namemap.get(restype, result.__class__.__name__)
+ resultstring += " (%.2f)" % (colitem.elapsedtime,)
+ self.out.line(resultstring)
+ else:
+ self.out.write(c)
# -------------------
# HEADER information
@@ -144,14 +161,6 @@
else:
raise TypeError, "not a result instance: %r" % testresult
- def repr_progress(self, colitem, result):
- restype, c = self._processresult(result)
- if self.option.verbose >= 1:
- resultstring = self.namemap.get(restype, result.__class__.__name__)
- self.out.line(resultstring)
- else:
- self.out.write(c)
-
# --------------------
# summary information
# --------------------
More information about the pytest-commit
mailing list