Show deprecation message when running under Python 2.7 and 3.4

Fix #4627
This commit is contained in:
Bruno Oliveira
2019-01-29 15:31:20 -02:00
parent 6aba60ab08
commit eb92e57509
4 changed files with 39 additions and 1 deletions

View File

@@ -3,6 +3,7 @@ from __future__ import division
from __future__ import print_function
import os
import sys
import pytest
from _pytest.warnings import SHOW_PYTEST_WARNINGS_ARG
@@ -219,3 +220,21 @@ def test_fixture_named_request(testdir):
"*'request' is a reserved name for fixtures and will raise an error in future versions"
]
)
def test_python_deprecation(testdir):
result = testdir.runpytest()
python_ver = ".".join(str(x) for x in sys.version_info[:3])
msg = "You are using Python {}, which will no longer be supported in pytest 5.0".format(
python_ver
)
if sys.version_info[:2] <= (3, 4):
result.stdout.fnmatch_lines(
[
msg,
"For more information, please read:",
" https://docs.pytest.org/en/latest/py27-py34-deprecation.html",
]
)
else:
assert msg not in result.stdout.str()