Hooks
pytest_robotframework._internal.pytest.hooks
new pytest hooks defined by the pytest_robotframework
plugin. these are not to be imported. see
the documentation for pytest hook functions
for information on how to use them.
pytest_robot_assertion(item, expression, fail_message, line_number, assertion_error, explanation)
gets called when an assertion runs. unlike pytest_assertrepr_compare
and
pytest_assertion_pass
, this hook is executed on both passing and failing assertions, and
allows you to see the second argument passed to assert
statement
requires the enable_assertion_pass_hook
pytest option to be enabled
Warning
this hook is experimental and relies heavily on patching the internals of pytest. it may break, change or be removed at any time. you should only use this hook if you know what you're doing
Parameters:
Name | Type | Description | Default |
---|---|---|---|
item
|
Item
|
the currently running item |
required |
expression
|
str
|
a string containing the the source code of the expression passed to the |
required |
fail_message
|
object
|
the second argument to the |
required |
line_number
|
int
|
the line number containing the |
required |
assertion_error
|
AssertionError | None
|
the exception raised if the |
required |
explanation
|
str
|
pytest's explanation of the result. the format will be different depending on whether the assertion passed or failed |
required |
Source code in pytest_robotframework/_internal/pytest/hooks.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
|
pytest_robot_modify_options(options, session)
modify the arguments passed to robot in-place
example:
def pytest_robot_modify_options(options: RobotOptions, session: Session) -> None:
if not session.config.option.collectonly:
options["loglevel"] = "DEBUG:INFO"
options["listener"].append(Foo())
Parameters:
Name | Type | Description | Default |
---|---|---|---|
options
|
RobotOptions
|
the arguments to be passed to robot in dict format. for example, |
required |
session
|
Session
|
the pytest |
required |
Source code in pytest_robotframework/_internal/pytest/hooks.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
|