test_ok1/testing/deprecated_test.py

47 lines
1.5 KiB
Python
Raw Normal View History

import pytest
from _pytest import deprecated
@pytest.mark.filterwarnings("default")
def test_resultlog_is_deprecated(testdir):
2018-05-23 22:48:46 +08:00
result = testdir.runpytest("--help")
result.stdout.fnmatch_lines(["*DEPRECATED path for machine-readable result log*"])
2018-05-23 22:48:46 +08:00
testdir.makepyfile(
"""
def test():
pass
2018-05-23 22:48:46 +08:00
"""
)
result = testdir.runpytest("--result-log=%s" % testdir.tmpdir.join("result.log"))
result.stdout.fnmatch_lines(
[
"*--result-log is deprecated and scheduled for removal in pytest 6.0*",
"*See https://docs.pytest.org/en/latest/deprecations.html#result-log-result-log for more information*",
2018-05-23 22:48:46 +08:00
]
)
2017-11-15 23:48:08 +08:00
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
2018-05-23 22:48:46 +08:00
pytest.skip("xdist workers disable the terminal reporter plugin")
except ImportError:
pass
2018-05-23 22:48:46 +08:00
terminal_reporter = pytestconfig.pluginmanager.get_plugin("terminalreporter")
assert terminal_reporter.writer is terminal_reporter._tw
@pytest.mark.parametrize("plugin", sorted(deprecated.DEPRECATED_EXTERNAL_PLUGINS))
@pytest.mark.filterwarnings("default")
def test_external_plugins_integrated(testdir, plugin):
testdir.syspathinsert()
testdir.makepyfile(**{plugin: ""})
with pytest.warns(pytest.PytestConfigWarning):
testdir.parseconfig("-p", plugin)