[py-svn] r56694 - in py/branch/event/py/test2: . testing
hpk at codespeak.net
hpk at codespeak.net
Sun Jul 20 19:14:03 CEST 2008
Author: hpk
Date: Sun Jul 20 19:14:02 2008
New Revision: 56694
Modified:
py/branch/event/py/test2/runner.py
py/branch/event/py/test2/testing/test_runner.py
Log:
* be less specific because setup/teardown might be misleading
in more
* refactor test setup a bit
Modified: py/branch/event/py/test2/runner.py
==============================================================================
--- py/branch/event/py/test2/runner.py (original)
+++ py/branch/event/py/test2/runner.py Sun Jul 20 19:14:02 2008
@@ -49,7 +49,7 @@
repr_run = item.repr_run(runnerinfo)
else:
repr_run = present.python_repr_run(item, runnerinfo,
- title="setupfailure with: %s" % (repr_path[1],))
+ title="failure during setup/teardown")
rep = repevent.ItemTestReport(trail, outcome, repr_run, repr_path)
if config.option.usepdb and rep.failed:
Modified: py/branch/event/py/test2/testing/test_runner.py
==============================================================================
--- py/branch/event/py/test2/testing/test_runner.py (original)
+++ py/branch/event/py/test2/testing/test_runner.py Sun Jul 20 19:14:02 2008
@@ -13,23 +13,30 @@
self.tmpdir = tmpdir.join("%s_%s" %
(self.__class__.__name__, method.__name__))
- def makeitem(self, func, funcname="testfunc"):
+ def getmodulecol(self, func, funcname="testfunc"):
funcname = getattr(func, '__name__', funcname)
self.tmpdir.ensure("__init__.py")
path = self.tmpdir.ensure(funcname + ".py")
path.write(py.code.Source(func))
self.config = py.test2.config._reparse([path.dirpath()])
modulecol = self.config._getcollector(path)
+ return modulecol
+
+ def makeitem(self, source, funcname="testfunc"):
+ modulecol = self.getmodulecol(source)
item = modulecol.join(funcname)
assert item is not None, (item, funcname)
return item
+ def getitems(self, source):
+ modulecol = self.getmodulecol(source)
+ return [modulecol.join(x) for x in modulecol.listdir()]
+
def runtestfunc(self, func, funcname="testfunc"):
item = self.makeitem(func, funcname=funcname)
runner = self.getrunner()
return runner(item)
-
def test_run_pass(self):
testrep = self.runtestfunc("""
def testfunc():
@@ -119,7 +126,7 @@
s = testrep.repr_run
print s
- exp = "setupfailure with: %s" %(testrep.repr_path[1])
+ exp = "failure during setup/teardown"
assert s.find(exp) != -1
i = s.find("def ")
assert s[i+4:].startswith("setup_module")
@@ -172,9 +179,6 @@
print s
i = s.find("def ")
assert s[i+4:].startswith("teardown_function")
- # xxx repr_run of setupfailures should always
- # display python Tracebacks starting from the
- # failing teardown function
class TestForkRunner(TestRunner):
def setup_class(cls):
More information about the pytest-commit
mailing list