[py-svn] r37624 - py/trunk/py/test/rsession
fijal at codespeak.net
fijal at codespeak.net
Tue Jan 30 17:59:37 CET 2007
Author: fijal
Date: Tue Jan 30 17:59:32 2007
New Revision: 37624
Modified:
py/trunk/py/test/rsession/executor.py
py/trunk/py/test/rsession/local.py
Log:
Slightly hackish way to put all tracing calls as low as possible. This
should kill unnecessary frames. Right now tracing is done only for
py.test.Function objects, I don't know what to do with sth else, let's
leave it alone.
Modified: py/trunk/py/test/rsession/executor.py
==============================================================================
--- py/trunk/py/test/rsession/executor.py (original)
+++ py/trunk/py/test/rsession/executor.py Tue Jan 30 17:59:32 2007
@@ -18,10 +18,13 @@
self.reporter = reporter
self.config = config
assert self.config
+
+ def run(self):
+ self.item.run()
def execute(self):
try:
- self.item.run()
+ self.run()
outcome = Outcome()
except py.test.Item.Skipped, e:
outcome = Outcome(skipped=str(e))
@@ -49,8 +52,33 @@
outcome.stderr = ""
return outcome
+class ApigenExecutor(RunExecutor):
+ """ Same as RunExecutor, but takes tracer to trace calls as
+ an argument to execute
+ """
+ def execute(self, tracer):
+ self.tracer = tracer
+ return super(ApigenExecutor, self).execute()
+
+ def wrap_underlaying(self, target):
+ def f(*args):
+ try:
+ self.tracer.start_tracing()
+ return target(*args)
+ finally:
+ self.tracer.end_tracing()
+ return f
+
+ def run(self):
+ """ We want to trace *only* function objects here. Unsure
+ what to do with custom collectors at all
+ """
+ if hasattr(self.item, 'obj') and type(self.item.obj) is py.test.Function:
+ self.item.obj = self.wrap_underlaying(self.item.obj)
+ self.item.run()
+
class BoxExecutor(RunExecutor):
- """ Same as run executor, but boxes test instead
+ """ Same as RunExecutor, but boxes test instead
"""
wraps = True
Modified: py/trunk/py/test/rsession/local.py
==============================================================================
--- py/trunk/py/test/rsession/local.py (original)
+++ py/trunk/py/test/rsession/local.py Tue Jan 30 17:59:32 2007
@@ -2,7 +2,8 @@
""" local-only operations
"""
-from py.__.test.rsession.executor import BoxExecutor, RunExecutor
+from py.__.test.rsession.executor import BoxExecutor, RunExecutor,\
+ ApigenExecutor
from py.__.test.rsession import report
from py.__.test.rsession.outcome import ReprOutcome
@@ -37,13 +38,10 @@
raise NotImplementedError()
def apigen_runner(item, session, reporter):
- r = RunExecutor(item, reporter=reporter, config=session.config)
startcapture(session)
#retval = plain_runner(item, session, reporter)
- r = RunExecutor(item, reporter=reporter, config=session.config)
- session.tracer.start_tracing()
- outcome = r.execute()
- session.tracer.end_tracing()
+ r = ApigenExecutor(item, reporter=reporter, config=session.config)
+ outcome = r.execute(session.tracer)
outcome = ReprOutcome(outcome.make_repr(session.config.option.tbstyle))
outcome.stdout, outcome.stderr = finishcapture(session)
return outcome
More information about the pytest-commit
mailing list