[svn r63163] fixing tests, better verbose output for dist-runs

--HG--
branch : trunk
This commit is contained in:
hpk 2009-03-21 03:04:44 +01:00
parent 6a1db0a594
commit 75bfb84ea5
9 changed files with 40 additions and 34 deletions

View File

@ -137,8 +137,7 @@ Instantiating a gateway from a string-specification
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)
>>>

View File

@ -212,7 +212,7 @@ class DSession(Session):
# "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:

View File

@ -124,6 +124,7 @@ class TestOptionsAndConfiguration:
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

View File

@ -43,6 +43,10 @@ class MasterNode(object):
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:

View File

@ -45,12 +45,6 @@ class InternalException(BaseEvent):
# 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

View File

@ -173,7 +173,7 @@ class PytestPluginHooks:
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):

View File

@ -133,19 +133,19 @@ class TerminalReporter:
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 @@ class TerminalReporter:
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 @@ class CollectonlyReporter:
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 @@ class TestTerminal:
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 @@ class TestTerminal:
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 @@ class TestCollectonly:
"<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'>",
])

View File

@ -50,7 +50,7 @@ class Session(object):
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)

View File

@ -361,10 +361,10 @@ class TestPyTest:
""")
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