From cf0cac3b734dd47c8f6cbf3afa759231fbb76bc9 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Thu, 30 Nov 2017 18:34:53 -0200 Subject: [PATCH] Bring back TerminalReporter.writer as an alias to TerminalReporter._tw Fix #2984 --- _pytest/terminal.py | 2 ++ changelog/2984.bugfix | 1 + testing/deprecated_test.py | 13 +++++++++++++ 3 files changed, 16 insertions(+) create mode 100644 changelog/2984.bugfix diff --git a/_pytest/terminal.py b/_pytest/terminal.py index 8538ee6aa2e..ca9b6e8e7ee 100644 --- a/_pytest/terminal.py +++ b/_pytest/terminal.py @@ -145,6 +145,8 @@ def __init__(self, config, file=None): if file is None: file = sys.stdout self._tw = _pytest.config.create_terminal_writer(config, file) + # self.writer will be deprecated in pytest-3.4 + self.writer = self._tw self._screen_width = self._tw.fullwidth self.currentfspath = None self.reportchars = getreportopt(config) diff --git a/changelog/2984.bugfix b/changelog/2984.bugfix new file mode 100644 index 00000000000..21f5748d523 --- /dev/null +++ b/changelog/2984.bugfix @@ -0,0 +1 @@ +Bring back ``TerminalReporter.writer`` as an alias to ``TerminalReporter._tw``. This alias was removed by accident in the ``3.3.0`` release. diff --git a/testing/deprecated_test.py b/testing/deprecated_test.py index f3c40cb3dbb..11c4ad43cbc 100644 --- a/testing/deprecated_test.py +++ b/testing/deprecated_test.py @@ -101,6 +101,19 @@ def test_func(i): ]) +def test_terminal_reporter_writer_attr(pytestconfig): + """Check that TerminalReporter._tw is also available as 'writer' (#2984) + This attribute is planned to be deprecated in 3.4. + """ + try: + import xdist # noqa + pytest.skip('xdist workers disable the terminal reporter plugin') + except ImportError: + pass + terminal_reporter = pytestconfig.pluginmanager.get_plugin('terminalreporter') + assert terminal_reporter.writer is terminal_reporter._tw + + def test_pytest_catchlog_deprecated(testdir): testdir.makepyfile(""" def test_func(pytestconfig):