summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelog/5585.breaking.rst2
-rw-r--r--doc/en/deprecations.rst16
-rw-r--r--src/_pytest/deprecated.py6
-rw-r--r--src/_pytest/terminal.py12
-rw-r--r--testing/deprecated_test.py31
5 files changed, 10 insertions, 57 deletions
diff --git a/changelog/5585.breaking.rst b/changelog/5585.breaking.rst
index c429324d2..3f71d3ece 100644
--- a/changelog/5585.breaking.rst
+++ b/changelog/5585.breaking.rst
@@ -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.
diff --git a/doc/en/deprecations.rst b/doc/en/deprecations.rst
index d5416b938..fb84647c5 100644
--- a/doc/en/deprecations.rst
+++ b/doc/en/deprecations.rst
@@ -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"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/src/_pytest/deprecated.py b/src/_pytest/deprecated.py
index 285d72265..839348282 100644
--- a/src/_pytest/deprecated.py
+++ b/src/_pytest/deprecated.py
@@ -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."
)
diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py
index 1d49df4cf..af6843000 100644
--- a/src/_pytest/terminal.py
+++ b/src/_pytest/terminal.py
@@ -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)
diff --git a/testing/deprecated_test.py b/testing/deprecated_test.py
index fb591d7d9..5660b312a 100644
--- a/testing/deprecated_test.py
+++ b/testing/deprecated_test.py
@@ -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):