Skip to content

Bring back TerminalReporter.writer as an alias to TerminalReporter._tw #2989

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions _pytest/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions changelog/2984.bugfix
Original file line number Diff line number Diff line change
@@ -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.
13 changes: 13 additions & 0 deletions testing/deprecated_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down