[py-svn] r63600 - in py/trunk/py/test: . dist dist/testing plugin
hpk at codespeak.net
hpk at codespeak.net
Sat Apr 4 02:34:21 CEST 2009
Author: hpk
Date: Sat Apr 4 02:34:20 2009
New Revision: 63600
Removed:
py/trunk/py/test/event.py
Modified:
py/trunk/py/test/dist/dsession.py
py/trunk/py/test/dist/testing/test_dsession.py
py/trunk/py/test/dist/testing/test_nodemanage.py
py/trunk/py/test/plugin/pytest_default.py
py/trunk/py/test/plugin/pytest_pytester.py
py/trunk/py/test/plugin/pytest_resultdb.py
py/trunk/py/test/plugin/pytest_resultlog.py
py/trunk/py/test/plugin/pytest_terminal.py
py/trunk/py/test/runner.py
Log:
merge remaining content of event.py into runner.py.
Modified: py/trunk/py/test/dist/dsession.py
==============================================================================
--- py/trunk/py/test/dist/dsession.py (original)
+++ py/trunk/py/test/dist/dsession.py Sat Apr 4 02:34:20 2009
@@ -5,7 +5,7 @@
"""
import py
-from py.__.test.runner import basic_run_report, basic_collect_report
+from py.__.test.runner import basic_run_report, basic_collect_report, ItemTestReport
from py.__.test.session import Session
from py.__.test import outcome
from py.__.test.dist.nodemanage import NodeManager
@@ -236,9 +236,8 @@
self.node2pending[node].remove(item)
def handle_crashitem(self, item, node):
- from py.__.test import event
longrepr = "!!! Node %r crashed during running of test %r" %(node, item)
- rep = event.ItemTestReport(item, when="???", excinfo=longrepr)
+ rep = ItemTestReport(item, when="???", excinfo=longrepr)
rep.node = node
self.bus.notify("itemtestreport", rep)
Modified: py/trunk/py/test/dist/testing/test_dsession.py
==============================================================================
--- py/trunk/py/test/dist/testing/test_dsession.py (original)
+++ py/trunk/py/test/dist/testing/test_dsession.py Sat Apr 4 02:34:20 2009
@@ -1,6 +1,5 @@
from py.__.test.dist.dsession import DSession
from py.__.test.runner import basic_collect_report
-from py.__.test import event
from py.__.test import outcome
import py
Modified: py/trunk/py/test/dist/testing/test_nodemanage.py
==============================================================================
--- py/trunk/py/test/dist/testing/test_nodemanage.py (original)
+++ py/trunk/py/test/dist/testing/test_nodemanage.py Sat Apr 4 02:34:20 2009
@@ -5,8 +5,6 @@
import py
from py.__.test.dist.nodemanage import NodeManager
-from py.__.test import event
-
def pytest_funcarg__source(pyfuncitem):
return py.test.ensuretemp(pyfuncitem.getmodpath()).mkdir("source")
def pytest_funcarg__dest(pyfuncitem):
Deleted: /py/trunk/py/test/event.py
==============================================================================
--- /py/trunk/py/test/event.py Sat Apr 4 02:34:20 2009
+++ (empty file)
@@ -1,90 +0,0 @@
-"""
- test collection and execution events
-"""
-
-import py
-import time
-from py.__.test.outcome import Skipped
-
-# ----------------------------------------------------------------------
-# Events related to collecting and executing test Items
-# ----------------------------------------------------------------------
-
-class BaseReport(object):
- def __repr__(self):
- l = ["%s=%s" %(key, value)
- for key, value in self.__dict__.items()]
- return "<%s %s>" %(self.__class__.__name__, " ".join(l),)
-
- def toterminal(self, out):
- longrepr = self.longrepr
- if hasattr(longrepr, 'toterminal'):
- longrepr.toterminal(out)
- else:
- out.line(str(longrepr))
-
-class ItemTestReport(BaseReport):
- """ Test Execution Report. """
- failed = passed = skipped = False
-
- def __init__(self, colitem, excinfo=None, when=None, outerr=None):
- self.colitem = colitem
- if colitem and when != "setup":
- self.keywords = colitem.readkeywords()
- else:
- # if we fail during setup it might mean
- # we are not able to access the underlying object
- # this might e.g. happen if we are unpickled
- # and our parent collector did not collect us
- # (because it e.g. skipped for platform reasons)
- self.keywords = {}
- if not excinfo:
- self.passed = True
- self.shortrepr = "."
- else:
- self.when = when
- if not isinstance(excinfo, py.code.ExceptionInfo):
- self.failed = True
- shortrepr = "?"
- longrepr = excinfo
- elif excinfo.errisinstance(Skipped):
- self.skipped = True
- shortrepr = "s"
- longrepr = self.colitem._repr_failure_py(excinfo, outerr)
- else:
- self.failed = True
- shortrepr = self.colitem.shortfailurerepr
- if self.when == "execute":
- longrepr = self.colitem.repr_failure(excinfo, outerr)
- else: # exception in setup or teardown
- longrepr = self.colitem._repr_failure_py(excinfo, outerr)
- shortrepr = shortrepr.lower()
- self.shortrepr = shortrepr
- self.longrepr = longrepr
-
-
-class CollectionReport(BaseReport):
- """ Collection Report. """
- skipped = failed = passed = False
-
- def __init__(self, colitem, result, excinfo=None, outerr=None):
- self.colitem = colitem
- if not excinfo:
- self.passed = True
- self.result = result
- else:
- self.outerr = outerr
- self.longrepr = self.colitem._repr_failure_py(excinfo, outerr)
- if excinfo.errisinstance(Skipped):
- self.skipped = True
- self.reason = str(excinfo.value)
- else:
- self.failed = True
-
- def toterminal(self, out):
- longrepr = self.longrepr
- if hasattr(longrepr, 'toterminal'):
- longrepr.toterminal(out)
- else:
- out.line(str(longrepr))
-
Modified: py/trunk/py/test/plugin/pytest_default.py
==============================================================================
--- py/trunk/py/test/plugin/pytest_default.py (original)
+++ py/trunk/py/test/plugin/pytest_default.py Sat Apr 4 02:34:20 2009
@@ -14,8 +14,8 @@
return True
def pytest_item_makereport(self, item, excinfo, when, outerr):
- from py.__.test import event
- return event.ItemTestReport(item, excinfo, when, outerr)
+ from py.__.test import runner
+ return runner.ItemTestReport(item, excinfo, when, outerr)
def pytest_pyfunc_call(self, pyfuncitem, args, kwargs):
pyfuncitem.obj(*args, **kwargs)
Modified: py/trunk/py/test/plugin/pytest_pytester.py
==============================================================================
--- py/trunk/py/test/plugin/pytest_pytester.py (original)
+++ py/trunk/py/test/plugin/pytest_pytester.py Sat Apr 4 02:34:20 2009
@@ -4,7 +4,7 @@
import py
import inspect
-from py.__.test import event
+from py.__.test import runner
from py.__.test.config import Config as pytestConfig
import api
@@ -374,7 +374,7 @@
""" return a testreport whose dotted import path matches """
__tracebackhide__ = True
l = []
- for rep in self.get(event.ItemTestReport):
+ for rep in self.get(runner.ItemTestReport):
if inamepart in rep.colitem.listnames():
l.append(rep)
if not l:
@@ -397,23 +397,23 @@
bus.notify("anonymous")
assert recorder.events
assert not recorder.getfailures()
- rep = event.ItemTestReport(None, None)
+ rep = runner.ItemTestReport(None, None)
rep.passed = False
rep.failed = True
bus.notify("itemtestreport", rep)
failures = recorder.getfailures()
assert failures == [rep]
- failures = recorder.get(event.ItemTestReport)
+ failures = recorder.get(runner.ItemTestReport)
assert failures == [rep]
failures = recorder.getnamed("itemtestreport")
assert failures == [rep]
- rep = event.ItemTestReport(None, None)
+ rep = runner.ItemTestReport(None, None)
rep.passed = False
rep.skipped = True
bus.notify("itemtestreport", rep)
- rep = event.CollectionReport(None, None)
+ rep = runner.CollectionReport(None, None)
rep.passed = False
rep.failed = True
bus.notify("itemtestreport", rep)
Modified: py/trunk/py/test/plugin/pytest_resultdb.py
==============================================================================
--- py/trunk/py/test/plugin/pytest_resultdb.py (original)
+++ py/trunk/py/test/plugin/pytest_resultdb.py Sat Apr 4 02:34:20 2009
@@ -344,7 +344,6 @@
py.test.skip("Needs a rewrite for db version.")
# they are produced for example by a teardown failing
# at the end of the run
- from py.__.test import event
try:
raise ValueError
except ValueError:
Modified: py/trunk/py/test/plugin/pytest_resultlog.py
==============================================================================
--- py/trunk/py/test/plugin/pytest_resultlog.py (original)
+++ py/trunk/py/test/plugin/pytest_resultlog.py Sat Apr 4 02:34:20 2009
@@ -209,7 +209,6 @@
def test_internal_exception(self):
# they are produced for example by a teardown failing
# at the end of the run
- from py.__.test import event
try:
raise ValueError
except ValueError:
Modified: py/trunk/py/test/plugin/pytest_terminal.py
==============================================================================
--- py/trunk/py/test/plugin/pytest_terminal.py (original)
+++ py/trunk/py/test/plugin/pytest_terminal.py Sat Apr 4 02:34:20 2009
@@ -353,8 +353,7 @@
#
# ===============================================================================
-from py.__.test import event
-from py.__.test.runner import basic_run_report
+from py.__.test import runner
class TestTerminal:
@@ -373,7 +372,7 @@
rep.config.bus.notify("testrunstart")
for item in testdir.genitems([modcol]):
- ev = basic_run_report(item)
+ ev = runner.basic_run_report(item)
rep.config.bus.notify("itemtestreport", ev)
linecomp.assert_contains_lines([
"*test_pass_skip_fail.py .sF"
@@ -404,7 +403,7 @@
rep.config.bus.notify("itemstart", item, None)
s = linecomp.stringio.getvalue().strip()
assert s.endswith(item.name)
- rep.config.bus.notify("itemtestreport", basic_run_report(item))
+ rep.config.bus.notify("itemtestreport", runner.basic_run_report(item))
linecomp.assert_contains_lines([
"*test_pass_skip_fail_verbose.py:2: *test_ok*PASS*",
@@ -495,7 +494,7 @@
raise ValueError()
""")
rep = TerminalReporter(modcol.config, file=linecomp.stringio)
- reports = [basic_run_report(x) for x in modcol.collect()]
+ reports = [runner.basic_run_report(x) for x in modcol.collect()]
rep.pyevent__looponfailinfo(reports, [modcol.config.topdir])
linecomp.assert_contains_lines([
"*test_looponfailreport.py:2: assert 0",
@@ -521,7 +520,8 @@
rep.config.bus.notify("testrunstart")
rep.config.bus.notify("testrunstart")
for item in testdir.genitems([modcol]):
- rep.config.bus.notify("itemtestreport", basic_run_report(item))
+ rep.config.bus.notify("itemtestreport",
+ runner.basic_run_report(item))
rep.config.bus.notify("testrunfinish", exitstatus=1)
s = linecomp.stringio.getvalue()
if tbopt == "long":
@@ -569,7 +569,8 @@
bus.notify("testrunstart")
try:
for item in testdir.genitems([modcol]):
- bus.notify("itemtestreport", basic_run_report(item))
+ bus.notify("itemtestreport",
+ runner.basic_run_report(item))
except KeyboardInterrupt:
excinfo = py.code.ExceptionInfo()
else:
@@ -602,12 +603,12 @@
lineno = 3
message = "justso"
- ev1 = event.CollectionReport(None, None)
+ ev1 = runner.CollectionReport(None, None)
ev1.when = "execute"
ev1.skipped = True
ev1.longrepr = longrepr
- ev2 = event.ItemTestReport(None, excinfo=longrepr)
+ ev2 = runner.ItemTestReport(None, excinfo=longrepr)
ev2.skipped = True
l = folded_skips([ev1, ev2])
@@ -637,7 +638,7 @@
" <Function 'test_func'>",
])
rep.config.bus.notify( "collectionreport",
- event.CollectionReport(modcol, [], excinfo=None))
+ runner.CollectionReport(modcol, [], excinfo=None))
assert rep.indent == indent
def test_collectonly_skipped_module(self, testdir, linecomp):
Modified: py/trunk/py/test/runner.py
==============================================================================
--- py/trunk/py/test/runner.py (original)
+++ py/trunk/py/test/runner.py Sat Apr 4 02:34:20 2009
@@ -8,9 +8,7 @@
import py, os, sys
-from py.__.test import event
-from py.__.test.outcome import Exit
-from py.__.test.dist.mypickle import ImmutablePickler
+from py.__.test.outcome import Exit, Skipped
def basic_run_report(item, pdb=None):
""" return report about setting up and running a test item. """
@@ -54,14 +52,14 @@
raise
except:
excinfo = py.code.ExceptionInfo()
- return event.CollectionReport(collector, res, excinfo, outerr)
+ return CollectionReport(collector, res, excinfo, outerr)
from cPickle import Pickler, Unpickler
from cStringIO import StringIO
def forked_run_report(item, pdb=None):
EXITSTATUS_TESTEXIT = 4
-
+ from py.__.test.dist.mypickle import ImmutablePickler
ipickle = ImmutablePickler(uneven=0)
ipickle.selfmemoize(item.config)
def runforked():
@@ -86,4 +84,83 @@
("X", "CRASHED"),
("%s:%s: CRASHED with signal %d" %(path, lineno, result.signal)),
]
- return event.ItemTestReport(item, excinfo=longrepr, when="???")
+ return ItemTestReport(item, excinfo=longrepr, when="???")
+
+class BaseReport(object):
+ def __repr__(self):
+ l = ["%s=%s" %(key, value)
+ for key, value in self.__dict__.items()]
+ return "<%s %s>" %(self.__class__.__name__, " ".join(l),)
+
+ def toterminal(self, out):
+ longrepr = self.longrepr
+ if hasattr(longrepr, 'toterminal'):
+ longrepr.toterminal(out)
+ else:
+ out.line(str(longrepr))
+
+class ItemTestReport(BaseReport):
+ """ Test Execution Report. """
+ failed = passed = skipped = False
+
+ def __init__(self, colitem, excinfo=None, when=None, outerr=None):
+ self.colitem = colitem
+ if colitem and when != "setup":
+ self.keywords = colitem.readkeywords()
+ else:
+ # if we fail during setup it might mean
+ # we are not able to access the underlying object
+ # this might e.g. happen if we are unpickled
+ # and our parent collector did not collect us
+ # (because it e.g. skipped for platform reasons)
+ self.keywords = {}
+ if not excinfo:
+ self.passed = True
+ self.shortrepr = "."
+ else:
+ self.when = when
+ if not isinstance(excinfo, py.code.ExceptionInfo):
+ self.failed = True
+ shortrepr = "?"
+ longrepr = excinfo
+ elif excinfo.errisinstance(Skipped):
+ self.skipped = True
+ shortrepr = "s"
+ longrepr = self.colitem._repr_failure_py(excinfo, outerr)
+ else:
+ self.failed = True
+ shortrepr = self.colitem.shortfailurerepr
+ if self.when == "execute":
+ longrepr = self.colitem.repr_failure(excinfo, outerr)
+ else: # exception in setup or teardown
+ longrepr = self.colitem._repr_failure_py(excinfo, outerr)
+ shortrepr = shortrepr.lower()
+ self.shortrepr = shortrepr
+ self.longrepr = longrepr
+
+
+class CollectionReport(BaseReport):
+ """ Collection Report. """
+ skipped = failed = passed = False
+
+ def __init__(self, colitem, result, excinfo=None, outerr=None):
+ self.colitem = colitem
+ if not excinfo:
+ self.passed = True
+ self.result = result
+ else:
+ self.outerr = outerr
+ self.longrepr = self.colitem._repr_failure_py(excinfo, outerr)
+ if excinfo.errisinstance(Skipped):
+ self.skipped = True
+ self.reason = str(excinfo.value)
+ else:
+ self.failed = True
+
+ def toterminal(self, out):
+ longrepr = self.longrepr
+ if hasattr(longrepr, 'toterminal'):
+ longrepr.toterminal(out)
+ else:
+ out.line(str(longrepr))
+
More information about the pytest-commit
mailing list