Implement hack to issue warnings during config

Once we can capture warnings during the config stage, we can
then get rid of this function

Related to #2891
This commit is contained in:
Bruno Oliveira
2018-09-03 19:27:46 -03:00
parent 60499d221e
commit 0fffa6ba2f
7 changed files with 64 additions and 42 deletions

View File

@@ -526,7 +526,17 @@ def pytest_terminal_summary(terminalreporter, exitstatus):
@hookspec(historic=True)
def pytest_logwarning(message, code, nodeid, fslocation):
""" process a warning specified by a message, a code string,
"""
.. deprecated:: 3.8
This hook is will stop working in a future release.
pytest no longer triggers this hook, but the
terminal writer still implements it to display warnings issued by
:meth:`_pytest.config.Config.warn` and :meth:`_pytest.nodes.Node.warn`. Calling those functions will be
an error in future releases.
process a warning specified by a message, a code string,
a nodeid and fslocation (both of which may be None
if the warning is not tied to a particular node/location).
@@ -538,7 +548,7 @@ def pytest_logwarning(message, code, nodeid, fslocation):
@hookspec(historic=True)
def pytest_warning_captured(warning_message, when, item):
"""
Process a warning captured by the internal pytest plugin.
Process a warning captured by the internal pytest warnings plugin.
:param warnings.WarningMessage warning_message:
The captured warning. This is the same object produced by :py:func:`warnings.catch_warnings`, and contains
@@ -546,6 +556,8 @@ def pytest_warning_captured(warning_message, when, item):
:param str when:
Indicates when the warning was captured. Possible values:
* ``"config"``: during pytest configuration/initialization stage.
* ``"collect"``: during test collection.
* ``"runtest"``: during test execution.