[svn r63163] fixing tests, better verbose output for dist-runs
--HG-- branch : trunk
This commit is contained in:
parent
6a1db0a594
commit
75bfb84ea5
|
@ -137,8 +137,7 @@ Instantiating a gateway from a string-specification
|
||||||
To specify Gateways with a String::
|
To specify Gateways with a String::
|
||||||
|
|
||||||
>>> import py
|
>>> import py
|
||||||
>>> gwspec = py.execnet.GatewaySpec("popen")
|
>>> gw = py.execnet.makegateway("popen")
|
||||||
>>> gw = gwspec.makegateway()
|
|
||||||
>>> ex = gw.remote_exec("import sys ; channel.send(sys.executable)").receive()
|
>>> ex = gw.remote_exec("import sys ; channel.send(sys.executable)").receive()
|
||||||
>>> assert ex == py.std.sys.executable, (ex, py.std.sys.executable)
|
>>> assert ex == py.std.sys.executable, (ex, py.std.sys.executable)
|
||||||
>>>
|
>>>
|
||||||
|
|
|
@ -212,7 +212,7 @@ class DSession(Session):
|
||||||
# "sending same item %r to multiple "
|
# "sending same item %r to multiple "
|
||||||
# "not implemented" %(item,))
|
# "not implemented" %(item,))
|
||||||
self.item2node[item] = node
|
self.item2node[item] = node
|
||||||
self.bus.notify("itemstart", event.ItemStart(item, node))
|
self.bus.notify("itemstart", item, node)
|
||||||
pending.extend(sending)
|
pending.extend(sending)
|
||||||
tosend[:] = tosend[room:] # update inplace
|
tosend[:] = tosend[room:] # update inplace
|
||||||
if not tosend:
|
if not tosend:
|
||||||
|
|
|
@ -124,6 +124,7 @@ class TestOptionsAndConfiguration:
|
||||||
assert len(xspecs) == 3
|
assert len(xspecs) == 3
|
||||||
|
|
||||||
def test_getxspecs(self, testdir):
|
def test_getxspecs(self, testdir):
|
||||||
|
testdir.chdir()
|
||||||
config = testdir.parseconfig("--tx=popen", "--tx", "ssh=xyz")
|
config = testdir.parseconfig("--tx=popen", "--tx", "ssh=xyz")
|
||||||
xspecs = config.getxspecs()
|
xspecs = config.getxspecs()
|
||||||
assert len(xspecs) == 2
|
assert len(xspecs) == 2
|
||||||
|
|
|
@ -43,6 +43,10 @@ class MasterNode(object):
|
||||||
elif eventname == "slavefinished":
|
elif eventname == "slavefinished":
|
||||||
self._down = True
|
self._down = True
|
||||||
self.notify("testnodedown", self, None)
|
self.notify("testnodedown", self, None)
|
||||||
|
elif eventname == "itemtestreport":
|
||||||
|
rep = args[0]
|
||||||
|
rep.node = self
|
||||||
|
self.notify("itemtestreport", rep)
|
||||||
else:
|
else:
|
||||||
self.notify(eventname, *args, **kwargs)
|
self.notify(eventname, *args, **kwargs)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
|
|
@ -45,12 +45,6 @@ class InternalException(BaseEvent):
|
||||||
# Events related to collecting and executing test Items
|
# 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):
|
class Deselected(BaseEvent):
|
||||||
def __init__(self, items):
|
def __init__(self, items):
|
||||||
self.items = items
|
self.items = items
|
||||||
|
|
|
@ -173,7 +173,7 @@ class PytestPluginHooks:
|
||||||
def pyevent_internalerror(self, event):
|
def pyevent_internalerror(self, event):
|
||||||
""" called for internal errors. """
|
""" called for internal errors. """
|
||||||
|
|
||||||
def pyevent_itemstart(self, event):
|
def pyevent_itemstart(self, item, node):
|
||||||
""" test item gets collected. """
|
""" test item gets collected. """
|
||||||
|
|
||||||
def pyevent_itemtestreport(self, event):
|
def pyevent_itemtestreport(self, event):
|
||||||
|
|
|
@ -133,19 +133,19 @@ class TerminalReporter:
|
||||||
self.config.option.traceconfig and category.find("config") != -1:
|
self.config.option.traceconfig and category.find("config") != -1:
|
||||||
self.write_line("[%s] %s" %(category, msg))
|
self.write_line("[%s] %s" %(category, msg))
|
||||||
|
|
||||||
def pyevent_itemstart(self, event):
|
def pyevent_itemstart(self, item, node=None):
|
||||||
if self.config.option.verbose:
|
if self.config.option.debug:
|
||||||
info = event.item.repr_metainfo()
|
info = item.repr_metainfo()
|
||||||
line = info.verboseline(basedir=self.curdir) + " "
|
line = info.verboseline(basedir=self.curdir) + " "
|
||||||
extra = ""
|
extra = ""
|
||||||
if event.host:
|
if node:
|
||||||
extra = "-> " + str(event.host)
|
extra = "-> " + str(node.gateway.id)
|
||||||
self.write_ensure_prefix(line, extra)
|
self.write_ensure_prefix(line, extra)
|
||||||
else:
|
#else:
|
||||||
# ensure that the path is printed before the 1st test of
|
# # ensure that the path is printed before the 1st test of
|
||||||
# a module starts running
|
# # a module starts running
|
||||||
fspath = event.item.fspath
|
# fspath = item.fspath
|
||||||
self.write_fspath_result(fspath, "")
|
# self.write_fspath_result(fspath, "")
|
||||||
|
|
||||||
def pyevent_rescheduleitems(self, event):
|
def pyevent_rescheduleitems(self, event):
|
||||||
if self.config.option.debug:
|
if self.config.option.debug:
|
||||||
|
@ -167,7 +167,13 @@ class TerminalReporter:
|
||||||
else:
|
else:
|
||||||
info = event.colitem.repr_metainfo()
|
info = event.colitem.repr_metainfo()
|
||||||
line = info.verboseline(basedir=self.curdir) + " "
|
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):
|
def pyevent_collectionreport(self, event):
|
||||||
if not event.passed:
|
if not event.passed:
|
||||||
|
@ -294,8 +300,8 @@ class CollectonlyReporter:
|
||||||
self.outindent(event.collector)
|
self.outindent(event.collector)
|
||||||
self.indent += self.INDENT
|
self.indent += self.INDENT
|
||||||
|
|
||||||
def pyevent_itemstart(self, event):
|
def pyevent_itemstart(self, item, node=None):
|
||||||
self.outindent(event.item)
|
self.outindent(item)
|
||||||
|
|
||||||
def pyevent_collectionreport(self, event):
|
def pyevent_collectionreport(self, event):
|
||||||
if not event.passed:
|
if not event.passed:
|
||||||
|
@ -389,16 +395,17 @@ class TestTerminal:
|
||||||
rep.config.bus.register(rep)
|
rep.config.bus.register(rep)
|
||||||
rep.config.bus.notify("testrunstart", event.TestrunStart())
|
rep.config.bus.notify("testrunstart", event.TestrunStart())
|
||||||
items = modcol.collect()
|
items = modcol.collect()
|
||||||
|
rep.config.option.debug = True #
|
||||||
for item in items:
|
for item in items:
|
||||||
rep.config.bus.notify("itemstart", event.ItemStart(item))
|
rep.config.bus.notify("itemstart", item, None)
|
||||||
s = linecomp.stringio.getvalue().strip()
|
s = linecomp.stringio.getvalue().strip()
|
||||||
assert s.endswith(item.name)
|
assert s.endswith(item.name)
|
||||||
rep.config.bus.notify("itemtestreport", basic_run_report(item))
|
rep.config.bus.notify("itemtestreport", basic_run_report(item))
|
||||||
|
|
||||||
linecomp.assert_contains_lines([
|
linecomp.assert_contains_lines([
|
||||||
"*test_pass_skip_fail_verbose.py:2: *test_ok*PASS",
|
"*PASS*test_pass_skip_fail_verbose.py:2: *test_ok*",
|
||||||
"*test_pass_skip_fail_verbose.py:4: *test_skip*SKIP",
|
"*SKIP*test_pass_skip_fail_verbose.py:4: *test_skip*",
|
||||||
"*test_pass_skip_fail_verbose.py:6: *test_func*FAIL",
|
"*FAIL*test_pass_skip_fail_verbose.py:6: *test_func*",
|
||||||
])
|
])
|
||||||
rep.config.bus.notify("testrunfinish", event.TestrunFinish())
|
rep.config.bus.notify("testrunfinish", event.TestrunFinish())
|
||||||
linecomp.assert_contains_lines([
|
linecomp.assert_contains_lines([
|
||||||
|
@ -536,7 +543,8 @@ class TestTerminal:
|
||||||
modcol.config.bus.register(rep)
|
modcol.config.bus.register(rep)
|
||||||
l = list(testdir.genitems([modcol]))
|
l = list(testdir.genitems([modcol]))
|
||||||
assert len(l) == 1
|
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([
|
linecomp.assert_contains_lines([
|
||||||
"*test_show_path_before_running_test.py*"
|
"*test_show_path_before_running_test.py*"
|
||||||
])
|
])
|
||||||
|
@ -619,7 +627,7 @@ class TestCollectonly:
|
||||||
"<Module 'test_collectonly_basic.py'>"
|
"<Module 'test_collectonly_basic.py'>"
|
||||||
])
|
])
|
||||||
item = modcol.join("test_func")
|
item = modcol.join("test_func")
|
||||||
rep.config.bus.notify("itemstart", event.ItemStart(item))
|
rep.config.bus.notify("itemstart", item)
|
||||||
linecomp.assert_contains_lines([
|
linecomp.assert_contains_lines([
|
||||||
" <Function 'test_func'>",
|
" <Function 'test_func'>",
|
||||||
])
|
])
|
||||||
|
|
|
@ -50,7 +50,7 @@ class Session(object):
|
||||||
if isinstance(next, Item):
|
if isinstance(next, Item):
|
||||||
remaining = self.filteritems([next])
|
remaining = self.filteritems([next])
|
||||||
if remaining:
|
if remaining:
|
||||||
notify("itemstart", event.ItemStart(next))
|
notify("itemstart", next)
|
||||||
yield next
|
yield next
|
||||||
else:
|
else:
|
||||||
assert isinstance(next, Collector)
|
assert isinstance(next, Collector)
|
||||||
|
|
|
@ -361,10 +361,10 @@ class TestPyTest:
|
||||||
""")
|
""")
|
||||||
result = testdir.runpytest(p1, '-v')
|
result = testdir.runpytest(p1, '-v')
|
||||||
result.stdout.fnmatch_lines([
|
result.stdout.fnmatch_lines([
|
||||||
"*test_verbose_reporting.py:2: test_fail*FAIL",
|
"*FAIL*test_verbose_reporting.py:2: test_fail*",
|
||||||
"*test_verbose_reporting.py:4: test_pass*PASS",
|
"*PASS*test_verbose_reporting.py:4: test_pass*",
|
||||||
"*test_verbose_reporting.py:7: TestClass.test_skip*SKIP",
|
"*SKIP*test_verbose_reporting.py:7: TestClass.test_skip*",
|
||||||
"*test_verbose_reporting.py:10: test_gen*FAIL",
|
"*FAIL*test_verbose_reporting.py:10: test_gen*",
|
||||||
])
|
])
|
||||||
assert result.ret == 1
|
assert result.ret == 1
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue