[svn r63885] moving two more events
--HG-- branch : trunk
This commit is contained in:
parent
e6234fdb61
commit
68c6aaa355
|
@ -98,6 +98,13 @@ class PluginHooks:
|
||||||
def pytest_testnodedown(self, node, error):
|
def pytest_testnodedown(self, node, error):
|
||||||
""" Test Node is down. """
|
""" Test Node is down. """
|
||||||
|
|
||||||
|
def pytest_testrunstart(self):
|
||||||
|
""" whole test run starts. """
|
||||||
|
|
||||||
|
def pytest_testrunfinish(self, exitstatus, excrepr=None):
|
||||||
|
""" whole test run finishes. """
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Events:
|
class Events:
|
||||||
# Events
|
# Events
|
||||||
|
@ -116,19 +123,6 @@ class Events:
|
||||||
def pyevent__deselected(self, items):
|
def pyevent__deselected(self, items):
|
||||||
""" collected items that were deselected (by keyword). """
|
""" collected items that were deselected (by keyword). """
|
||||||
|
|
||||||
|
|
||||||
def pyevent__testrunstart(self):
|
|
||||||
""" whole test run starts. """
|
|
||||||
|
|
||||||
def pyevent__testrunfinish(self, exitstatus, excrepr=None):
|
|
||||||
""" whole test run finishes. """
|
|
||||||
|
|
||||||
def pyevent__gwmanage_newgateway(self, gateway):
|
|
||||||
""" execnet gateway manager has instantiated a gateway.
|
|
||||||
The gateway will have an 'id' attribute that is unique
|
|
||||||
within the gateway manager context.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def pytest_rescheduleitems(self, items):
|
def pytest_rescheduleitems(self, items):
|
||||||
""" reschedule Items from a node that went down. """
|
""" reschedule Items from a node that went down. """
|
||||||
|
|
||||||
|
|
|
@ -21,11 +21,11 @@ class ExecnetcleanupPlugin:
|
||||||
if self._gateways is not None:
|
if self._gateways is not None:
|
||||||
self._gateways.remove(gateway)
|
self._gateways.remove(gateway)
|
||||||
|
|
||||||
def pyevent__testrunstart(self):
|
def pytest_testrunstart(self):
|
||||||
self.trace("testrunstart")
|
self.trace("testrunstart")
|
||||||
self._gateways = []
|
self._gateways = []
|
||||||
|
|
||||||
def pyevent__testrunfinish(self, exitstatus, excrepr=None):
|
def pytest_testrunfinish(self, exitstatus, excrepr=None):
|
||||||
self.trace("testrunfinish", exitstatus)
|
self.trace("testrunfinish", exitstatus)
|
||||||
l = []
|
l = []
|
||||||
for gw in self._gateways:
|
for gw in self._gateways:
|
||||||
|
|
|
@ -194,7 +194,7 @@ class TerminalReporter:
|
||||||
self.stats.setdefault("skipped", []).append(rep)
|
self.stats.setdefault("skipped", []).append(rep)
|
||||||
self.write_fspath_result(rep.colitem.fspath, "S")
|
self.write_fspath_result(rep.colitem.fspath, "S")
|
||||||
|
|
||||||
def pyevent__testrunstart(self):
|
def pytest_testrunstart(self):
|
||||||
self.write_sep("=", "test session starts", bold=True)
|
self.write_sep("=", "test session starts", bold=True)
|
||||||
self._sessionstarttime = py.std.time.time()
|
self._sessionstarttime = py.std.time.time()
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ class TerminalReporter:
|
||||||
for i, testarg in py.builtin.enumerate(self.config.args):
|
for i, testarg in py.builtin.enumerate(self.config.args):
|
||||||
self.write_line("test object %d: %s" %(i+1, testarg))
|
self.write_line("test object %d: %s" %(i+1, testarg))
|
||||||
|
|
||||||
def pyevent__testrunfinish(self, exitstatus, excrepr=None):
|
def pytest_testrunfinish(self, exitstatus, excrepr=None):
|
||||||
self._tw.line("")
|
self._tw.line("")
|
||||||
if exitstatus in (0, 1, 2):
|
if exitstatus in (0, 1, 2):
|
||||||
self.summary_failures()
|
self.summary_failures()
|
||||||
|
@ -322,7 +322,7 @@ class CollectonlyReporter:
|
||||||
self._failed.append(rep)
|
self._failed.append(rep)
|
||||||
self.indent = self.indent[:-len(self.INDENT)]
|
self.indent = self.indent[:-len(self.INDENT)]
|
||||||
|
|
||||||
def pyevent__testrunfinish(self, exitstatus, excrepr=None):
|
def pytest_testrunfinish(self, exitstatus, excrepr=None):
|
||||||
if self._failed:
|
if self._failed:
|
||||||
self.out.sep("!", "collection failures")
|
self.out.sep("!", "collection failures")
|
||||||
for rep in self._failed:
|
for rep in self._failed:
|
||||||
|
@ -369,7 +369,7 @@ class TestTerminal:
|
||||||
""")
|
""")
|
||||||
rep = TerminalReporter(modcol.config, file=linecomp.stringio)
|
rep = TerminalReporter(modcol.config, file=linecomp.stringio)
|
||||||
rep.config.bus.register(rep)
|
rep.config.bus.register(rep)
|
||||||
rep.config.bus.notify("testrunstart")
|
rep.config.api.pytest_testrunstart()
|
||||||
|
|
||||||
for item in testdir.genitems([modcol]):
|
for item in testdir.genitems([modcol]):
|
||||||
ev = runner.basic_run_report(item)
|
ev = runner.basic_run_report(item)
|
||||||
|
@ -377,7 +377,7 @@ class TestTerminal:
|
||||||
linecomp.assert_contains_lines([
|
linecomp.assert_contains_lines([
|
||||||
"*test_pass_skip_fail.py .sF"
|
"*test_pass_skip_fail.py .sF"
|
||||||
])
|
])
|
||||||
rep.config.bus.notify("testrunfinish", exitstatus=1)
|
rep.config.api.pytest_testrunfinish(exitstatus=1)
|
||||||
linecomp.assert_contains_lines([
|
linecomp.assert_contains_lines([
|
||||||
" def test_func():",
|
" def test_func():",
|
||||||
"> assert 0",
|
"> assert 0",
|
||||||
|
@ -396,7 +396,7 @@ class TestTerminal:
|
||||||
""", configargs=("-v",))
|
""", configargs=("-v",))
|
||||||
rep = TerminalReporter(modcol.config, file=linecomp.stringio)
|
rep = TerminalReporter(modcol.config, file=linecomp.stringio)
|
||||||
rep.config.bus.register(rep)
|
rep.config.bus.register(rep)
|
||||||
rep.config.bus.notify("testrunstart")
|
rep.config.api.pytest_testrunstart()
|
||||||
items = modcol.collect()
|
items = modcol.collect()
|
||||||
rep.config.option.debug = True #
|
rep.config.option.debug = True #
|
||||||
for item in items:
|
for item in items:
|
||||||
|
@ -410,7 +410,7 @@ class TestTerminal:
|
||||||
"*test_pass_skip_fail_verbose.py:4: *test_skip*SKIP*",
|
"*test_pass_skip_fail_verbose.py:4: *test_skip*SKIP*",
|
||||||
"*test_pass_skip_fail_verbose.py:6: *test_func*FAIL*",
|
"*test_pass_skip_fail_verbose.py:6: *test_func*FAIL*",
|
||||||
])
|
])
|
||||||
rep.config.bus.notify("testrunfinish", exitstatus=1)
|
rep.config.api.pytest_testrunfinish(exitstatus=1)
|
||||||
linecomp.assert_contains_lines([
|
linecomp.assert_contains_lines([
|
||||||
" def test_func():",
|
" def test_func():",
|
||||||
"> assert 0",
|
"> assert 0",
|
||||||
|
@ -421,13 +421,13 @@ class TestTerminal:
|
||||||
modcol = testdir.getmodulecol("import xyz")
|
modcol = testdir.getmodulecol("import xyz")
|
||||||
rep = TerminalReporter(modcol.config, file=linecomp.stringio)
|
rep = TerminalReporter(modcol.config, file=linecomp.stringio)
|
||||||
rep.config.bus.register(rep)
|
rep.config.bus.register(rep)
|
||||||
rep.config.bus.notify("testrunstart")
|
rep.config.api.pytest_testrunstart()
|
||||||
l = list(testdir.genitems([modcol]))
|
l = list(testdir.genitems([modcol]))
|
||||||
assert len(l) == 0
|
assert len(l) == 0
|
||||||
linecomp.assert_contains_lines([
|
linecomp.assert_contains_lines([
|
||||||
"*test_collect_fail.py F*"
|
"*test_collect_fail.py F*"
|
||||||
])
|
])
|
||||||
rep.config.bus.notify("testrunfinish", exitstatus=1)
|
rep.config.api.pytest_testrunfinish(exitstatus=1)
|
||||||
linecomp.assert_contains_lines([
|
linecomp.assert_contains_lines([
|
||||||
"> import xyz",
|
"> import xyz",
|
||||||
"E ImportError: No module named xyz"
|
"E ImportError: No module named xyz"
|
||||||
|
@ -517,12 +517,11 @@ class TestTerminal:
|
||||||
""", configargs=("--tb=%s" % tbopt,))
|
""", configargs=("--tb=%s" % tbopt,))
|
||||||
rep = TerminalReporter(modcol.config, file=linecomp.stringio)
|
rep = TerminalReporter(modcol.config, file=linecomp.stringio)
|
||||||
rep.config.bus.register(rep)
|
rep.config.bus.register(rep)
|
||||||
rep.config.bus.notify("testrunstart")
|
rep.config.api.pytest_testrunstart()
|
||||||
rep.config.bus.notify("testrunstart")
|
|
||||||
for item in testdir.genitems([modcol]):
|
for item in testdir.genitems([modcol]):
|
||||||
rep.config.api.pytest_itemtestreport(
|
rep.config.api.pytest_itemtestreport(
|
||||||
rep=runner.basic_run_report(item))
|
rep=runner.basic_run_report(item))
|
||||||
rep.config.bus.notify("testrunfinish", exitstatus=1)
|
rep.config.api.pytest_testrunfinish(exitstatus=1)
|
||||||
s = linecomp.stringio.getvalue()
|
s = linecomp.stringio.getvalue()
|
||||||
if tbopt == "long":
|
if tbopt == "long":
|
||||||
print s
|
print s
|
||||||
|
@ -566,7 +565,7 @@ class TestTerminal:
|
||||||
rep = TerminalReporter(modcol.config, file=linecomp.stringio)
|
rep = TerminalReporter(modcol.config, file=linecomp.stringio)
|
||||||
modcol.config.bus.register(rep)
|
modcol.config.bus.register(rep)
|
||||||
bus = modcol.config.bus
|
bus = modcol.config.bus
|
||||||
bus.notify("testrunstart")
|
modcol.config.api.pytest_testrunstart()
|
||||||
try:
|
try:
|
||||||
for item in testdir.genitems([modcol]):
|
for item in testdir.genitems([modcol]):
|
||||||
modcol.config.api.pytest_itemtestreport(
|
modcol.config.api.pytest_itemtestreport(
|
||||||
|
@ -578,7 +577,7 @@ class TestTerminal:
|
||||||
s = linecomp.stringio.getvalue()
|
s = linecomp.stringio.getvalue()
|
||||||
if not verbose:
|
if not verbose:
|
||||||
assert s.find("_keyboard_interrupt.py Fs") != -1
|
assert s.find("_keyboard_interrupt.py Fs") != -1
|
||||||
bus.notify("testrunfinish", exitstatus=2, excrepr=excinfo.getrepr())
|
modcol.config.api.pytest_testrunfinish(exitstatus=2, excrepr=excinfo.getrepr())
|
||||||
text = linecomp.stringio.getvalue()
|
text = linecomp.stringio.getvalue()
|
||||||
linecomp.assert_contains_lines([
|
linecomp.assert_contains_lines([
|
||||||
" def test_foobar():",
|
" def test_foobar():",
|
||||||
|
|
|
@ -78,7 +78,7 @@ class Session(object):
|
||||||
|
|
||||||
def sessionstarts(self):
|
def sessionstarts(self):
|
||||||
""" setup any neccessary resources ahead of the test run. """
|
""" setup any neccessary resources ahead of the test run. """
|
||||||
self.bus.notify("testrunstart")
|
self.config.api.pytest_testrunstart()
|
||||||
|
|
||||||
def pytest_itemtestreport(self, rep):
|
def pytest_itemtestreport(self, rep):
|
||||||
if rep.failed:
|
if rep.failed:
|
||||||
|
@ -89,9 +89,10 @@ class Session(object):
|
||||||
|
|
||||||
def sessionfinishes(self, exitstatus=0, excinfo=None):
|
def sessionfinishes(self, exitstatus=0, excinfo=None):
|
||||||
""" teardown any resources after a test run. """
|
""" teardown any resources after a test run. """
|
||||||
self.bus.notify("testrunfinish",
|
self.config.api.pytest_testrunfinish(
|
||||||
exitstatus=exitstatus,
|
exitstatus=exitstatus,
|
||||||
excrepr=excinfo and excinfo.getrepr() or None)
|
excrepr=excinfo and excinfo.getrepr() or None
|
||||||
|
)
|
||||||
|
|
||||||
def getinitialitems(self, colitems):
|
def getinitialitems(self, colitems):
|
||||||
if colitems is None:
|
if colitems is None:
|
||||||
|
|
Loading…
Reference in New Issue