Skip to content

Commit 2e8b0a8

Browse files
Merge pull request #2989 from nicoddemus/bring-tr-writer-back-2984
Bring back TerminalReporter.writer as an alias to TerminalReporter._tw
2 parents 369c711 + cf0cac3 commit 2e8b0a8

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

_pytest/terminal.py

+2
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ def __init__(self, config, file=None):
145145
if file is None:
146146
file = sys.stdout
147147
self._tw = _pytest.config.create_terminal_writer(config, file)
148+
# self.writer will be deprecated in pytest-3.4
149+
self.writer = self._tw
148150
self._screen_width = self._tw.fullwidth
149151
self.currentfspath = None
150152
self.reportchars = getreportopt(config)

changelog/2984.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Bring back ``TerminalReporter.writer`` as an alias to ``TerminalReporter._tw``. This alias was removed by accident in the ``3.3.0`` release.

testing/deprecated_test.py

+13
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,19 @@ def test_func(i):
101101
])
102102

103103

104+
def test_terminal_reporter_writer_attr(pytestconfig):
105+
"""Check that TerminalReporter._tw is also available as 'writer' (#2984)
106+
This attribute is planned to be deprecated in 3.4.
107+
"""
108+
try:
109+
import xdist # noqa
110+
pytest.skip('xdist workers disable the terminal reporter plugin')
111+
except ImportError:
112+
pass
113+
terminal_reporter = pytestconfig.pluginmanager.get_plugin('terminalreporter')
114+
assert terminal_reporter.writer is terminal_reporter._tw
115+
116+
104117
def test_pytest_catchlog_deprecated(testdir):
105118
testdir.makepyfile("""
106119
def test_func(pytestconfig):

0 commit comments

Comments
 (0)