diff --git a/tests/functional/test_warning.py b/tests/functional/test_warning.py index 20f246795..6c097c75b 100644 --- a/tests/functional/test_warning.py +++ b/tests/functional/test_warning.py @@ -1,21 +1,22 @@ +import textwrap + def test_environ(script, tmpdir): """$PYTHONWARNINGS was added in python2.7""" demo = tmpdir.join('warnings_demo.py') - demo.write(''' -from pip._internal.utils import deprecation -deprecation.install_warning_logger() + demo.write(textwrap.dedent(''' + from logging import basicConfig + from pip._internal.utils import deprecation -from logging import basicConfig -basicConfig() + deprecation.install_warning_logger() + basicConfig() -from warnings import warn -warn("deprecated!", deprecation.PipDeprecationWarning) -''') + deprecation.deprecated("deprecated!", replacement=None, gone_in=None) + ''')) result = script.run('python', demo, expect_stderr=True) - assert result.stderr == \ - 'ERROR:pip._internal.deprecations:DEPRECATION: deprecated!\n' + expected = 'WARNING:pip._internal.deprecations:DEPRECATION: deprecated!\n' + assert result.stderr == expected script.environ['PYTHONWARNINGS'] = 'ignore' result = script.run('python', demo)