[py-svn] r33764 - in py/dist/py/test/rsession: . testing
fijal at codespeak.net
fijal at codespeak.net
Thu Oct 26 14:12:37 CEST 2006
Author: fijal
Date: Thu Oct 26 14:12:35 2006
New Revision: 33764
Modified:
py/dist/py/test/rsession/box.py
py/dist/py/test/rsession/rsession.py
py/dist/py/test/rsession/testing/test_reporter.py
py/dist/py/test/rsession/testing/test_slave.py
Log:
Added more tests.
Modified: py/dist/py/test/rsession/box.py
==============================================================================
--- py/dist/py/test/rsession/box.py (original)
+++ py/dist/py/test/rsession/box.py Thu Oct 26 14:12:35 2006
@@ -133,6 +133,8 @@
pass
class FileBox(object):
+ count = 0
+
def __init__(self, fun, args=None, kwargs=None):
if args is None:
args = []
@@ -143,7 +145,8 @@
self.kwargs = kwargs
def run(self):
- tempdir = py.test.ensuretemp("box")
+ tempdir = py.test.ensuretemp("box%d" % self.count)
+ self.count += 1
self.tempdir = tempdir
self.PYTESTRETVAL = tempdir.join('retval')
self.PYTESTSTDOUT = tempdir.join('stdout')
@@ -196,6 +199,7 @@
self.signal = exitstat & 0x7f
self.exitstat = exitstat & 0xff00
+
if not exitstat:
retval = self.PYTESTRETVAL.open()
try:
Modified: py/dist/py/test/rsession/rsession.py
==============================================================================
--- py/dist/py/test/rsession/rsession.py (original)
+++ py/dist/py/test/rsession/rsession.py Thu Oct 26 14:12:35 2006
@@ -34,7 +34,7 @@
remote_options = RemoteOptions({'we_are_remote':False})
class AbstractReporter(object):
- def __init__(self, config, hosts, pkgdir=""):
+ def __init__(self, config, hosts, pkgdir=py.path.local(py.__file__)):
self.config = config
self.pkgdir = pkgdir
self.failed_tests_outcome = []
Modified: py/dist/py/test/rsession/testing/test_reporter.py
==============================================================================
--- py/dist/py/test/rsession/testing/test_reporter.py (original)
+++ py/dist/py/test/rsession/testing/test_reporter.py Thu Oct 26 14:12:35 2006
@@ -3,19 +3,19 @@
test if it *works*, not if the output produced is what we really like
"""
-import py
-from py.__.test.rsession.rsession import LocalReporter
-from py.__.test.rsession.report import ReceivedItemOutcome
+import py, os
+from py.__.test.rsession.rsession import LocalReporter, AbstractSession
+from py.__.test.rsession.report import ReceivedItemOutcome, ItemStart
from py.__.test.rsession.outcome import ReprOutcome, Outcome
-from py.__.test.rsession.testing.test_slave import funcpass_spec
+from py.__.test.rsession.testing.test_slave import funcpass_spec, mod_spec
+from py.__.test.rsession.box import Box
+#from py.__.test.
def setup_module(mod):
mod.pkgdir = py.path.local(py.__file__).dirpath()
class TestReporter(object):
- def test_report_received_item_outcome(self):
- config, args = py.test.Config.parse(["some_sub"])
- r = LocalReporter(config, ["localhost"])
+ def prepare_outcomes(self):
# possible outcomes
try:
1/0
@@ -31,8 +31,69 @@
outcomes[3].signal = 11
outcomes[0].passed = False
+ return outcomes
+
+ def test_report_received_item_outcome(self):
+ config, args = py.test.Config.parse(["some_sub"])
# we just go...
rootcol = py.test.collect.Directory(pkgdir.dirpath())
item = rootcol.getitembynames(funcpass_spec)
- for outcome in outcomes:
- r.report(ReceivedItemOutcome(None, item, outcome))
+ outcomes = self.prepare_outcomes()
+
+ def boxfun(config, item, outcomes):
+ r = LocalReporter(config, ["localhost"])
+ for outcome in outcomes:
+ r.report(ReceivedItemOutcome(None, item, outcome))
+
+ b = Box(boxfun, [config, item, outcomes])
+ b.run()
+ assert b.stdoutrepr == 'FsF.'
+
+ def test_module(self):
+ config, args = py.test.Config.parse(["some_sub"])
+ # we just go...
+ rootcol = py.test.collect.Directory(pkgdir.dirpath())
+ funcitem = rootcol.getitembynames(funcpass_spec)
+ moditem = rootcol.getitembynames(mod_spec)
+ outcomes = self.prepare_outcomes()
+
+ def boxfun(pkgdir, config, item, funcitem, outcomes):
+ r = LocalReporter(config, ["localhost"])
+ #r.pkgdir = pkdgir
+ r.report(ItemStart(item))
+ for outcome in outcomes:
+ r.report(ReceivedItemOutcome(None, funcitem, outcome))
+
+ b = Box(boxfun, [pkgdir, config, moditem, funcitem, outcomes])
+ b.run()
+ assert b.stdoutrepr.endswith("test_slave.py[8] FsF."),\
+ b.stdoutrepr
+ assert not b.stderrrepr
+
+ def test_full_module(self):
+ tmpdir = py.test.ensuretemp("repmod")
+ tmpdir.ensure("__init__.py")
+ tmpdir.ensure("test_one.py").write(py.code.Source("""
+ def test_x():
+ pass
+ """))
+ tmpdir.ensure("test_two.py").write(py.code.Source("""
+ import py
+ py.test.skip("reason")
+ """))
+ tmpdir.ensure("test_three.py").write(py.code.Source("""
+ sadsadsa
+ """))
+
+ def boxfun():
+ config, args = py.test.Config.parse([str(tmpdir)])
+ rootcol = py.test.collect.Directory(tmpdir)
+ r = LocalReporter(config, ["localhost"])
+ list(rootcol.tryiter(reporterror=lambda x : AbstractSession.reporterror(r.report, x)))
+
+ b = Box(boxfun)
+ b.run()
+ assert b.stdoutrepr == """
+repmod/test_one.py[1]
+repmod/test_three.py[0] - FAILED TO LOAD MODULE
+repmod/test_two.py[0] - skipped (reason)"""
Modified: py/dist/py/test/rsession/testing/test_slave.py
==============================================================================
--- py/dist/py/test/rsession/testing/test_slave.py (original)
+++ py/dist/py/test/rsession/testing/test_slave.py Thu Oct 26 14:12:35 2006
@@ -45,6 +45,7 @@
funcprintfail_spec = (BASE + "funcprintfail").split("/")
funcoption_spec = (BASE + "funcoption").split("/")
funcoptioncustom_spec = (BASE + "funcoptioncustom").split("/")
+mod_spec = BASE[:-1].split("/")
# ----------------------------------------------------------------------
More information about the pytest-commit
mailing list