Skip to content
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

Add option to silence warnings related to deprecation of Python versions #6739

Merged
merged 12 commits into from
Dec 15, 2019
Merged
36 changes: 36 additions & 0 deletions tests/functional/test_warning.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,39 @@ def test_deprecation_warnings_can_be_silenced(script, warnings_demo):
script.environ['PYTHONWARNINGS'] = 'ignore'
result = script.run('python', warnings_demo)
assert result.stderr == ''


deprecation_message = "DEPRECATION: Python 2.7 will reach the" \
" end of its life on January 1st, 2020." \
" Please upgrade your Python as Python 2.7" \
" won't be maintained after that date. " \
"A future version of pip will drop support" \
" for Python 2.7. More details about Python 2" \
" support in pip, can be found at" \
" https://pip.pypa.io/en/latest/development/release-process/#python-2-support" # noqa


@pytest.mark.skipif(
"sys.version_info[:2] in [(2, 7)] "
chrahunt marked this conversation as resolved.
Show resolved Hide resolved
"and platform.python_implementation() == 'CPython'")
chrahunt marked this conversation as resolved.
Show resolved Hide resolved
def test_version_warning_is_not_shown_if_python_version_is_not_27(script):
result = script.pip("debug", allow_stderr_warning=True)
assert deprecation_message not in result.stderr, str(result)


@pytest.mark.skipif(
"not (sys.version_info[:2] in [(2, 7)] "
"and platform.python_implementation() == 'CPython')")
def test_version_warning_is_shown_if_python_version_is_27(script):
result = script.pip("debug", allow_stderr_warning=True)
assert deprecation_message in result.stderr, str(result)


@pytest.mark.skipif(
"not (sys.version_info[:2] in [(2, 7)] "
"and platform.python_implementation() == 'CPython')")
def test_version_warning_is_not_shown_when_flag_is_passed(script):
result = script.pip("debug", "--no-python-version-warning",
chrahunt marked this conversation as resolved.
Show resolved Hide resolved
allow_stderr_warning=True)
assert deprecation_message not in result.stderr, str(result)
assert "--no-python-version-warning" not in result.stderr