Improve docs and reference
This commit is contained in:
parent
fcbe66feba
commit
3afee36ebb
|
@ -1,2 +1,4 @@
|
||||||
Adds ``pytest_assertion_pass`` hook, called with assertion context information
|
New `pytest_assertion_pass <https://docs.pytest.org/en/latest/reference.html#_pytest.hookspec.pytest_assertion_pass>`__
|
||||||
(original asssertion statement and pytest explanation) whenever an assertion passes.
|
hook, called with context information when an assertion *passes*.
|
||||||
|
|
||||||
|
This hook is still **experimental** so use it with caution.
|
||||||
|
|
|
@ -665,15 +665,14 @@ Session related reporting hooks:
|
||||||
.. autofunction:: pytest_fixture_post_finalizer
|
.. autofunction:: pytest_fixture_post_finalizer
|
||||||
.. autofunction:: pytest_warning_captured
|
.. autofunction:: pytest_warning_captured
|
||||||
|
|
||||||
And here is the central hook for reporting about
|
Central hook for reporting about test execution:
|
||||||
test execution:
|
|
||||||
|
|
||||||
.. autofunction:: pytest_runtest_logreport
|
.. autofunction:: pytest_runtest_logreport
|
||||||
|
|
||||||
You can also use this hook to customize assertion representation for some
|
Assertion related hooks:
|
||||||
types:
|
|
||||||
|
|
||||||
.. autofunction:: pytest_assertrepr_compare
|
.. autofunction:: pytest_assertrepr_compare
|
||||||
|
.. autofunction:: pytest_assertion_pass
|
||||||
|
|
||||||
|
|
||||||
Debugging/Interaction hooks
|
Debugging/Interaction hooks
|
||||||
|
|
|
@ -486,13 +486,27 @@ def pytest_assertrepr_compare(config, op, left, right):
|
||||||
|
|
||||||
|
|
||||||
def pytest_assertion_pass(item, lineno, orig, expl):
|
def pytest_assertion_pass(item, lineno, orig, expl):
|
||||||
"""Process explanation when assertions are valid.
|
"""
|
||||||
|
**(Experimental)**
|
||||||
|
|
||||||
|
Hook called whenever an assertion *passes*.
|
||||||
|
|
||||||
Use this hook to do some processing after a passing assertion.
|
Use this hook to do some processing after a passing assertion.
|
||||||
The original assertion information is available in the `orig` string
|
The original assertion information is available in the `orig` string
|
||||||
and the pytest introspected assertion information is available in the
|
and the pytest introspected assertion information is available in the
|
||||||
`expl` string.
|
`expl` string.
|
||||||
|
|
||||||
|
This hook must be explicitly enabled by the ``enable_assertion_pass_hook``
|
||||||
|
ini-file option:
|
||||||
|
|
||||||
|
.. code-block:: ini
|
||||||
|
|
||||||
|
[pytest]
|
||||||
|
enable_assertion_pass_hook=true
|
||||||
|
|
||||||
|
You need to **clean the .pyc** files in your project directory and interpreter libraries
|
||||||
|
when enabling this option, as assertions will require to be re-written.
|
||||||
|
|
||||||
:param _pytest.nodes.Item item: pytest item object of current test
|
:param _pytest.nodes.Item item: pytest item object of current test
|
||||||
:param int lineno: line number of the assert statement
|
:param int lineno: line number of the assert statement
|
||||||
:param string orig: string with original assertion
|
:param string orig: string with original assertion
|
||||||
|
@ -500,12 +514,9 @@ def pytest_assertion_pass(item, lineno, orig, expl):
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
This hook is still *experimental*, so its parameters or even the hook itself might
|
This hook is **experimental**, so its parameters or even the hook itself might
|
||||||
be changed/removed without warning in any future pytest release.
|
be changed/removed without warning in any future pytest release.
|
||||||
|
|
||||||
It should be enabled using the `enable_assertion_pass_hook` ini-file option.
|
|
||||||
Remember to clean the .pyc files in your project directory and interpreter libraries.
|
|
||||||
|
|
||||||
If you find this hook useful, please share your feedback opening an issue.
|
If you find this hook useful, please share your feedback opening an issue.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue