Remove deprecated TerminalReporter.writer property
This commit is contained in:
parent
345a59dd53
commit
457d351941
|
@ -8,3 +8,5 @@ removed:
|
|||
* Direct construction of ``Node`` subclasses now raise an error, use ``from_parent`` instead.
|
||||
|
||||
* The default value for ``junit_family`` has changed to ``xunit2``. If you require the old format, add ``junit_family=xunit1`` to your configuration file.
|
||||
|
||||
* The ``TerminalReporter`` no longer has a ``writer`` attribute. Plugin authors may use the public functions of the ``TerminalReporter`` instead of accessing the ``TerminalWriter`` object directly.
|
||||
|
|
|
@ -82,10 +82,17 @@ The plan is remove the ``--result-log`` option in pytest 6.0 if ``pytest-reportl
|
|||
to all users and is deemed stable. The ``pytest-reportlog`` plugin might even be merged into the core
|
||||
at some point, depending on the plans for the plugins and number of users using it.
|
||||
|
||||
|
||||
Removed Features
|
||||
----------------
|
||||
|
||||
As stated in our :ref:`backwards-compatibility` policy, deprecated features are removed only in major releases after
|
||||
an appropriate period of deprecation has passed.
|
||||
|
||||
TerminalReporter.writer
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. deprecated:: 5.4
|
||||
.. versionremoved:: 6.0
|
||||
|
||||
The ``TerminalReporter.writer`` attribute has been deprecated and should no longer be used. This
|
||||
was inadvertently exposed as part of the public API of that plugin and ties it too much
|
||||
|
@ -94,13 +101,6 @@ with ``py.io.TerminalWriter``.
|
|||
Plugins that used ``TerminalReporter.writer`` directly should instead use ``TerminalReporter``
|
||||
methods that provide the same functionality.
|
||||
|
||||
|
||||
Removed Features
|
||||
----------------
|
||||
|
||||
As stated in our :ref:`backwards-compatibility` policy, deprecated features are removed only in major releases after
|
||||
an appropriate period of deprecation has passed.
|
||||
|
||||
``junit_family`` default value change to "xunit2"
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
|
@ -42,12 +42,6 @@ PYTEST_COLLECT_MODULE = UnformattedWarning(
|
|||
)
|
||||
|
||||
|
||||
TERMINALWRITER_WRITER = PytestDeprecationWarning(
|
||||
"The TerminalReporter.writer attribute is deprecated, use TerminalReporter._tw instead at your own risk.\n"
|
||||
"See https://docs.pytest.org/en/stable/deprecations.html#terminalreporter-writer for more information."
|
||||
)
|
||||
|
||||
|
||||
MINUS_K_DASH = PytestDeprecationWarning(
|
||||
"The `-k '-expr'` syntax to -k is deprecated.\nUse `-k 'not expr'` instead."
|
||||
)
|
||||
|
|
|
@ -31,7 +31,6 @@ from _pytest import nodes
|
|||
from _pytest import timing
|
||||
from _pytest._code import ExceptionInfo
|
||||
from _pytest._code.code import ExceptionRepr
|
||||
from _pytest._io import TerminalWriter
|
||||
from _pytest._io.wcwidth import wcswidth
|
||||
from _pytest.compat import order_preserving_dict
|
||||
from _pytest.compat import TYPE_CHECKING
|
||||
|
@ -39,7 +38,6 @@ from _pytest.config import _PluggyPlugin
|
|||
from _pytest.config import Config
|
||||
from _pytest.config import ExitCode
|
||||
from _pytest.config.argparsing import Parser
|
||||
from _pytest.deprecated import TERMINALWRITER_WRITER
|
||||
from _pytest.nodes import Item
|
||||
from _pytest.nodes import Node
|
||||
from _pytest.reports import BaseReport
|
||||
|
@ -335,16 +333,6 @@ class TerminalReporter:
|
|||
self._already_displayed_warnings = None # type: Optional[int]
|
||||
self._keyboardinterrupt_memo = None # type: Optional[ExceptionRepr]
|
||||
|
||||
@property
|
||||
def writer(self) -> TerminalWriter:
|
||||
warnings.warn(TERMINALWRITER_WRITER, stacklevel=2)
|
||||
return self._tw
|
||||
|
||||
@writer.setter
|
||||
def writer(self, value: TerminalWriter) -> None:
|
||||
warnings.warn(TERMINALWRITER_WRITER, stacklevel=2)
|
||||
self._tw = value
|
||||
|
||||
def _determine_show_progress_info(self) -> "Literal['progress', 'count', False]":
|
||||
"""Return whether we should display progress information based on the current config."""
|
||||
# do not show progress if we are not capturing output (#3038)
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
import copy
|
||||
import warnings
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
from _pytest import deprecated
|
||||
from _pytest.config import Config
|
||||
from _pytest.pytester import Testdir
|
||||
|
||||
|
||||
|
@ -36,35 +34,6 @@ def test_pytest_collect_module_deprecated(attribute):
|
|||
getattr(pytest.collect, attribute)
|
||||
|
||||
|
||||
def test_terminal_reporter_writer_attr(pytestconfig: Config) -> None:
|
||||
"""Check that TerminalReporter._tw is also available as 'writer' (#2984)
|
||||
This attribute has been deprecated in 5.4.
|
||||
"""
|
||||
try:
|
||||
import xdist # noqa
|
||||
|
||||
pytest.skip("xdist workers disable the terminal reporter plugin")
|
||||
except ImportError:
|
||||
pass
|
||||
terminal_reporter = pytestconfig.pluginmanager.get_plugin("terminalreporter")
|
||||
original_tw = terminal_reporter._tw
|
||||
|
||||
with pytest.warns(pytest.PytestDeprecationWarning) as cw:
|
||||
assert terminal_reporter.writer is original_tw
|
||||
assert len(cw) == 1
|
||||
assert cw[0].filename == __file__
|
||||
|
||||
new_tw = copy.copy(original_tw)
|
||||
with pytest.warns(pytest.PytestDeprecationWarning) as cw:
|
||||
terminal_reporter.writer = new_tw
|
||||
try:
|
||||
assert terminal_reporter._tw is new_tw
|
||||
finally:
|
||||
terminal_reporter.writer = original_tw
|
||||
assert len(cw) == 2
|
||||
assert cw[0].filename == cw[1].filename == __file__
|
||||
|
||||
|
||||
@pytest.mark.parametrize("plugin", sorted(deprecated.DEPRECATED_EXTERNAL_PLUGINS))
|
||||
@pytest.mark.filterwarnings("default")
|
||||
def test_external_plugins_integrated(testdir, plugin):
|
||||
|
|
Loading…
Reference in New Issue