Merge pull request #2989 from nicoddemus/bring-tr-writer-back-2984

Bring back TerminalReporter.writer as an alias to TerminalReporter._tw
This commit is contained in:
Ronny Pfannschmidt 2017-12-01 17:42:31 +01:00 committed by GitHub
commit 2e8b0a83fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 0 deletions

View File

@ -145,6 +145,8 @@ class TerminalReporter:
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)

1
changelog/2984.bugfix Normal file
View File

@ -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.

View File

@ -101,6 +101,19 @@ def test_metafunc_addcall_deprecated(testdir):
])
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):