How to use _define method in Slash

Best Python code snippet using slash

hooks.py

Source:hooks.py Github

copy

Full Screen

...6 """7 return gossip.register('slash.{0}'.format(func.__name__))(func)8def _deprecated_to_gossip(func):9 return deprecated(since="0.6.0", message="Use gossip instead")(func)10def _define(hook_name, **kwargs):11 hook = gossip.define("slash.{0}".format(hook_name), **kwargs)12 globals()[hook_name] = hook13 return hook14_define('session_start', doc="Called right after session starts")15_define('session_end', doc="Called right before the session ends, regardless of the reason for termination")16_define('session_interrupt', doc='Called when the session is interrupted unexpectedly')17_define('tests_loaded', doc='Called when Slash finishes loading a batch of tests for execution (not necessarily al tests)', arg_names=('tests',))18_define('before_session_start', doc="Entry point which is called before session_start, useful for configuring plugins and other global resources")19_define('after_session_start', doc="Second entry point for session start, useful for plugins relying on other plugins' session_start routine")20_define('configure', doc='Configuration hook that happens during commandline parsing, and before plugins are activated. It is a convenient point to override plugin activation settings') # pylint: disable=line-too-long21_define('test_interrupt', doc="Called when a test is interrupted by a KeyboardInterrupt or other similar means")22_define('test_avoided', doc="Called when a test is skipped completely (not even started)", arg_names=('reason',))23_define('test_start', doc="Called right after a test starts")24_define('test_distributed', doc="Called in parallel mode, after the parent sent a test to child)", arg_names=('test_logical_id', 'worker_session_id',)) # pylint: disable=line-too-long25_define('test_end', doc="Called right before a test ends, regardless of the reason for termination")26_define('log_file_closed', doc="Called right after a log file was closed")27_define('before_test_cleanups', doc="Called right before a test cleanups are executed")28_define('test_success', doc="Called on test success")29_define('test_error', doc="Called on test error")30_define('test_failure', doc="Called on test failure")31_define('test_skip', doc="Called on test skip", arg_names=("reason",))32_define('worker_connected', doc="Called on new worker startup", arg_names=("session_id",))33_define('error_added', doc='Called when an error is added to a result (either test result or global)', arg_names=('error', 'result'))34_define('interruption_added', doc='Called when an exception is encountered that triggers test or session interruption',35 arg_names=('result', 'exception'))36_define('fact_set', doc='Called when a fact is set for a test', arg_names=['name', 'value'])37_define('warning_added', doc='Called when a warning is captured by Slash', arg_names=('warning',))38_define('result_summary', doc="Called at the end of the execution, when printing results")39_define('exception_caught_before_debugger',40 doc="Called whenever an exception is caught, but a debugger hasn't been entered yet")41_define('entering_debugger', doc='Called right before entering debugger', arg_names=('exc_info',))42_define('exception_caught_after_debugger',43 doc="Called whenever an exception is caught, and a debugger has already been run")44_define('before_worker_start', doc="Called in parallel execution mode, before the parent starts the child worker",45 arg_names=("worker_config",))46_define('prepare_notification', doc='Called with a message object prior to it being sent via the notifications plugin (if enabled)',47 arg_names=("message",))48_slash_group = gossip.get_group('slash')49_slash_group.set_strict()50_slash_group.set_exception_policy(gossip.RaiseDefer())51@gossip.register('gossip.on_handler_exception') # pylint: disable=unused-argument52def debugger(handler, exception, hook): # pylint: disable=unused-argument53 from .exception_handling import handle_exception54 if hook.group is _slash_group and config.root.debug.debug_hook_handlers:55 handle_exception(exception)56@_deprecated_to_gossip57def add_custom_hook(hook_name):58 """59 Adds an additional hook to the set of available hooks60 """61 return _define(hook_name)62@_deprecated_to_gossip63def ensure_custom_hook(hook_name):64 """65 Like :func:`.add_custom_hook`, only forgives if the hook already exists66 """67 try:68 return gossip.get_hook("slash.{0}".format(hook_name))69 except LookupError:70 return _define(hook_name)71@_deprecated_to_gossip72def remove_custom_hook(hook_name):73 """74 Removes a hook from the set of available hooks75 """76 gossip.get_hook("slash.{0}".format(hook_name)).undefine()77 globals().pop(hook_name)78@_deprecated_to_gossip79def get_custom_hook_names():80 """81 Retrieves the names of all custom hooks currently installed82 """83 raise NotImplementedError() # pragma: no cover84@_deprecated_to_gossip...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Slash automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful