[py-svn] r63163 - in py/trunk/py: doc test test/dsession test/dsession/testing test/plugin test/testing
hpk at codespeak.net
hpk at codespeak.net
Sat Mar 21 03:04:47 CET 2009
Author: hpk
Date: Sat Mar 21 03:04:44 2009
New Revision: 63163
Modified:
py/trunk/py/doc/execnet.txt
py/trunk/py/test/dsession/dsession.py
py/trunk/py/test/dsession/testing/test_nodemanage.py
py/trunk/py/test/dsession/txnode.py
py/trunk/py/test/event.py
py/trunk/py/test/plugin/pytest_plugintester.py
py/trunk/py/test/plugin/pytest_terminal.py
py/trunk/py/test/session.py
py/trunk/py/test/testing/acceptance_test.py
Log:
fixing tests, better verbose output for dist-runs
Modified: py/trunk/py/doc/execnet.txt
==============================================================================
--- py/trunk/py/doc/execnet.txt (original)
+++ py/trunk/py/doc/execnet.txt Sat Mar 21 03:04:44 2009
@@ -137,8 +137,7 @@
To specify Gateways with a String::
>>> import py
- >>> gwspec = py.execnet.GatewaySpec("popen")
- >>> gw = gwspec.makegateway()
+ >>> gw = py.execnet.makegateway("popen")
>>> ex = gw.remote_exec("import sys ; channel.send(sys.executable)").receive()
>>> assert ex == py.std.sys.executable, (ex, py.std.sys.executable)
>>>
Modified: py/trunk/py/test/dsession/dsession.py
==============================================================================
--- py/trunk/py/test/dsession/dsession.py (original)
+++ py/trunk/py/test/dsession/dsession.py Sat Mar 21 03:04:44 2009
@@ -212,7 +212,7 @@
# "sending same item %r to multiple "
# "not implemented" %(item,))
self.item2node[item] = node
- self.bus.notify("itemstart", event.ItemStart(item, node))
+ self.bus.notify("itemstart", item, node)
pending.extend(sending)
tosend[:] = tosend[room:] # update inplace
if not tosend:
Modified: py/trunk/py/test/dsession/testing/test_nodemanage.py
==============================================================================
--- py/trunk/py/test/dsession/testing/test_nodemanage.py (original)
+++ py/trunk/py/test/dsession/testing/test_nodemanage.py Sat Mar 21 03:04:44 2009
@@ -124,6 +124,7 @@
assert len(xspecs) == 3
def test_getxspecs(self, testdir):
+ testdir.chdir()
config = testdir.parseconfig("--tx=popen", "--tx", "ssh=xyz")
xspecs = config.getxspecs()
assert len(xspecs) == 2
Modified: py/trunk/py/test/dsession/txnode.py
==============================================================================
--- py/trunk/py/test/dsession/txnode.py (original)
+++ py/trunk/py/test/dsession/txnode.py Sat Mar 21 03:04:44 2009
@@ -43,6 +43,10 @@
elif eventname == "slavefinished":
self._down = True
self.notify("testnodedown", self, None)
+ elif eventname == "itemtestreport":
+ rep = args[0]
+ rep.node = self
+ self.notify("itemtestreport", rep)
else:
self.notify(eventname, *args, **kwargs)
except KeyboardInterrupt:
Modified: py/trunk/py/test/event.py
==============================================================================
--- py/trunk/py/test/event.py (original)
+++ py/trunk/py/test/event.py Sat Mar 21 03:04:44 2009
@@ -45,12 +45,6 @@
# Events related to collecting and executing test Items
# ----------------------------------------------------------------------
-class ItemStart(BaseEvent):
- def __init__(self, item, host=None):
- self.item = item
- self.host = host
- self.time = timestamp()
-
class Deselected(BaseEvent):
def __init__(self, items):
self.items = items
Modified: py/trunk/py/test/plugin/pytest_plugintester.py
==============================================================================
--- py/trunk/py/test/plugin/pytest_plugintester.py (original)
+++ py/trunk/py/test/plugin/pytest_plugintester.py Sat Mar 21 03:04:44 2009
@@ -173,7 +173,7 @@
def pyevent_internalerror(self, event):
""" called for internal errors. """
- def pyevent_itemstart(self, event):
+ def pyevent_itemstart(self, item, node):
""" test item gets collected. """
def pyevent_itemtestreport(self, event):
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 Mar 21 03:04:44 2009
@@ -133,19 +133,19 @@
self.config.option.traceconfig and category.find("config") != -1:
self.write_line("[%s] %s" %(category, msg))
- def pyevent_itemstart(self, event):
- if self.config.option.verbose:
- info = event.item.repr_metainfo()
+ def pyevent_itemstart(self, item, node=None):
+ if self.config.option.debug:
+ info = item.repr_metainfo()
line = info.verboseline(basedir=self.curdir) + " "
extra = ""
- if event.host:
- extra = "-> " + str(event.host)
+ if node:
+ extra = "-> " + str(node.gateway.id)
self.write_ensure_prefix(line, extra)
- else:
- # ensure that the path is printed before the 1st test of
- # a module starts running
- fspath = event.item.fspath
- self.write_fspath_result(fspath, "")
+ #else:
+ # # ensure that the path is printed before the 1st test of
+ # # a module starts running
+ # fspath = item.fspath
+ # self.write_fspath_result(fspath, "")
def pyevent_rescheduleitems(self, event):
if self.config.option.debug:
@@ -167,7 +167,13 @@
else:
info = event.colitem.repr_metainfo()
line = info.verboseline(basedir=self.curdir) + " "
- self.write_ensure_prefix(line, word, **markup)
+ #self.write_ensure_prefix(line, word, **markup)
+ self.ensure_newline()
+ if hasattr(event, 'node'):
+ self._tw.write("%s " % event.node.gateway.id)
+ self._tw.write(word, **markup)
+ self._tw.write(" " + line)
+ self.currentfspath = -2
def pyevent_collectionreport(self, event):
if not event.passed:
@@ -294,8 +300,8 @@
self.outindent(event.collector)
self.indent += self.INDENT
- def pyevent_itemstart(self, event):
- self.outindent(event.item)
+ def pyevent_itemstart(self, item, node=None):
+ self.outindent(item)
def pyevent_collectionreport(self, event):
if not event.passed:
@@ -389,16 +395,17 @@
rep.config.bus.register(rep)
rep.config.bus.notify("testrunstart", event.TestrunStart())
items = modcol.collect()
+ rep.config.option.debug = True #
for item in items:
- rep.config.bus.notify("itemstart", event.ItemStart(item))
+ 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))
linecomp.assert_contains_lines([
- "*test_pass_skip_fail_verbose.py:2: *test_ok*PASS",
- "*test_pass_skip_fail_verbose.py:4: *test_skip*SKIP",
- "*test_pass_skip_fail_verbose.py:6: *test_func*FAIL",
+ "*PASS*test_pass_skip_fail_verbose.py:2: *test_ok*",
+ "*SKIP*test_pass_skip_fail_verbose.py:4: *test_skip*",
+ "*FAIL*test_pass_skip_fail_verbose.py:6: *test_func*",
])
rep.config.bus.notify("testrunfinish", event.TestrunFinish())
linecomp.assert_contains_lines([
@@ -536,7 +543,8 @@
modcol.config.bus.register(rep)
l = list(testdir.genitems([modcol]))
assert len(l) == 1
- rep.config.bus.notify("itemstart", event.ItemStart(l[0]))
+ modcol.config.option.debug = True
+ rep.config.bus.notify("itemstart", l[0])
linecomp.assert_contains_lines([
"*test_show_path_before_running_test.py*"
])
@@ -619,7 +627,7 @@
"<Module 'test_collectonly_basic.py'>"
])
item = modcol.join("test_func")
- rep.config.bus.notify("itemstart", event.ItemStart(item))
+ rep.config.bus.notify("itemstart", item)
linecomp.assert_contains_lines([
" <Function 'test_func'>",
])
Modified: py/trunk/py/test/session.py
==============================================================================
--- py/trunk/py/test/session.py (original)
+++ py/trunk/py/test/session.py Sat Mar 21 03:04:44 2009
@@ -50,7 +50,7 @@
if isinstance(next, Item):
remaining = self.filteritems([next])
if remaining:
- notify("itemstart", event.ItemStart(next))
+ notify("itemstart", next)
yield next
else:
assert isinstance(next, Collector)
Modified: py/trunk/py/test/testing/acceptance_test.py
==============================================================================
--- py/trunk/py/test/testing/acceptance_test.py (original)
+++ py/trunk/py/test/testing/acceptance_test.py Sat Mar 21 03:04:44 2009
@@ -361,10 +361,10 @@
""")
result = testdir.runpytest(p1, '-v')
result.stdout.fnmatch_lines([
- "*test_verbose_reporting.py:2: test_fail*FAIL",
- "*test_verbose_reporting.py:4: test_pass*PASS",
- "*test_verbose_reporting.py:7: TestClass.test_skip*SKIP",
- "*test_verbose_reporting.py:10: test_gen*FAIL",
+ "*FAIL*test_verbose_reporting.py:2: test_fail*",
+ "*PASS*test_verbose_reporting.py:4: test_pass*",
+ "*SKIP*test_verbose_reporting.py:7: TestClass.test_skip*",
+ "*FAIL*test_verbose_reporting.py:10: test_gen*",
])
assert result.ret == 1
More information about the pytest-commit
mailing list