2009-04-03 03:16:57 +08:00
|
|
|
"""
|
|
|
|
API definitions for pytest plugin hooks and events
|
|
|
|
"""
|
|
|
|
|
|
|
|
class PluginHooks:
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Command line and configuration hooks
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
def pytest_addoption(self, parser):
|
|
|
|
""" called before commandline parsing. """
|
|
|
|
|
|
|
|
def pytest_configure(self, config):
|
|
|
|
""" called after command line options have been parsed.
|
|
|
|
and all plugins and initial conftest files been loaded.
|
|
|
|
``config`` provides access to all such configuration values.
|
|
|
|
"""
|
|
|
|
def pytest_unconfigure(self, config):
|
|
|
|
""" called before test process is exited.
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# collection hooks
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
def pytest_collect_file(self, path, parent):
|
|
|
|
""" return Collection node or None. """
|
|
|
|
|
|
|
|
def pytest_collect_recurse(self, path, parent):
|
|
|
|
""" return True/False to cause/prevent recursion into given directory.
|
|
|
|
return None if you do not want to make the decision.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def pytest_collect_directory(self, path, parent):
|
|
|
|
""" return Collection node or None. """
|
|
|
|
|
|
|
|
def pytest_pymodule_makeitem(self, modcol, name, obj):
|
|
|
|
""" return custom item/collector for a python object in a module, or None. """
|
|
|
|
|
2009-04-04 05:18:41 +08:00
|
|
|
def pytest_itemrun(self, item, pdb=None):
|
|
|
|
""" run given test item and return test report. """
|
|
|
|
|
2009-04-03 03:16:57 +08:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# runtest related hooks
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
def pytest_pyfunc_call(self, pyfuncitem, args, kwargs):
|
|
|
|
""" return True if we consumed/did the call to the python function item. """
|
|
|
|
|
|
|
|
def pytest_item_makereport(self, item, excinfo, when, outerr):
|
|
|
|
""" return ItemTestReport event for the given test outcome. """
|
|
|
|
|
|
|
|
# reporting hooks (invoked from pytest_terminal.py)
|
|
|
|
def pytest_report_teststatus(self, event):
|
|
|
|
""" return shortletter and verbose word. """
|
|
|
|
|
|
|
|
def pytest_terminal_summary(self, terminalreporter):
|
|
|
|
""" add additional section in terminal summary reporting. """
|
|
|
|
|
|
|
|
class Events:
|
|
|
|
# Events
|
2009-04-03 18:57:34 +08:00
|
|
|
def pyevent(self, eventname, args, kwargs):
|
2009-04-03 03:16:57 +08:00
|
|
|
""" generically called for each notification event. """
|
|
|
|
|
|
|
|
def pyevent__gateway_init(self, gateway):
|
|
|
|
""" called after a gateway has been initialized. """
|
|
|
|
|
|
|
|
def pyevent__gateway_exit(self, gateway):
|
|
|
|
""" called when gateway is being exited. """
|
|
|
|
|
|
|
|
def pyevent__gwmanage_rsyncstart(self, source, gateways):
|
|
|
|
""" called before rsyncing a directory to remote gateways takes place. """
|
|
|
|
|
|
|
|
def pyevent__gwmanage_rsyncfinish(self, source, gateways):
|
|
|
|
""" called after rsyncing a directory to remote gateways takes place. """
|
|
|
|
|
|
|
|
def pyevent__trace(self, category, msg):
|
|
|
|
""" called for tracing events. """
|
|
|
|
|
2009-04-03 22:18:47 +08:00
|
|
|
def pyevent__internalerror(self, excrepr):
|
2009-04-03 03:16:57 +08:00
|
|
|
""" called for internal errors. """
|
|
|
|
|
2009-04-03 18:57:34 +08:00
|
|
|
def pyevent__itemstart(self, item, node=None):
|
2009-04-03 03:16:57 +08:00
|
|
|
""" test item gets collected. """
|
|
|
|
|
|
|
|
def pyevent__itemtestreport(self, event):
|
|
|
|
""" test has been run. """
|
|
|
|
|
2009-04-05 04:19:18 +08:00
|
|
|
def pyevent__item_runtest_finished(self, item, excinfo, outerr):
|
2009-04-05 03:06:20 +08:00
|
|
|
""" test has been run. """
|
|
|
|
|
2009-04-05 04:19:18 +08:00
|
|
|
def pyevent__itemsetupreport(self, rep):
|
|
|
|
""" a report on running a fixture function. """
|
|
|
|
|
2009-04-03 23:47:16 +08:00
|
|
|
def pyevent__deselected(self, items):
|
|
|
|
""" collected items that were deselected (by keyword). """
|
2009-04-03 03:16:57 +08:00
|
|
|
|
2009-04-03 23:47:16 +08:00
|
|
|
def pyevent__collectionstart(self, collector):
|
2009-04-03 03:16:57 +08:00
|
|
|
""" collector starts collecting. """
|
|
|
|
|
|
|
|
def pyevent__collectionreport(self, event):
|
|
|
|
""" collector finished collecting. """
|
|
|
|
|
2009-04-03 18:57:34 +08:00
|
|
|
def pyevent__testrunstart(self):
|
2009-04-03 03:16:57 +08:00
|
|
|
""" whole test run starts. """
|
|
|
|
|
2009-04-03 20:18:25 +08:00
|
|
|
def pyevent__testrunfinish(self, exitstatus, excrepr=None):
|
2009-04-03 03:16:57 +08:00
|
|
|
""" 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 pyevent__testnodeready(self, node):
|
|
|
|
""" Test Node is ready to operate. """
|
|
|
|
|
|
|
|
def pyevent__testnodedown(self, node, error):
|
|
|
|
""" Test Node is down. """
|
|
|
|
|
2009-04-04 00:26:21 +08:00
|
|
|
def pyevent__rescheduleitems(self, items):
|
2009-04-03 03:16:57 +08:00
|
|
|
""" reschedule Items from a node that went down. """
|
|
|
|
|
2009-04-04 00:26:21 +08:00
|
|
|
def pyevent__looponfailinfo(self, failreports, rootdirs):
|
2009-04-03 03:16:57 +08:00
|
|
|
""" info for repeating failing tests. """
|
|
|
|
|
|
|
|
def pyevent__plugin_registered(self, plugin):
|
|
|
|
""" a new py lib plugin got registered. """
|
|
|
|
|
|
|
|
|