summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2014-04-28 22:56:08 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2014-04-28 22:56:08 (GMT)
commit6999441d62cfc6a6273b0e9e3df2cce0ef3f05fa (patch)
tree464a66cd5daa0eb45c7f6c11ec06fb6e2e065114 /Lib/test
parent7fae75a415cb0c8cac099f5d122d9b7bf3b104bf (diff)
downloadcpython-6999441d62cfc6a6273b0e9e3df2cce0ef3f05fa.zip
cpython-6999441d62cfc6a6273b0e9e3df2cce0ef3f05fa.tar.gz
cpython-6999441d62cfc6a6273b0e9e3df2cce0ef3f05fa.tar.bz2
Issue #20355: -W command line options now have higher priority than the PYTHONWARNINGS environment variable. Patch by Arfrever.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_warnings.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/Lib/test/test_warnings.py b/Lib/test/test_warnings.py
index eec2c24..cf7f747 100644
--- a/Lib/test/test_warnings.py
+++ b/Lib/test/test_warnings.py
@@ -5,7 +5,7 @@ from io import StringIO
import sys
import unittest
from test import support
-from test.script_helper import assert_python_ok
+from test.script_helper import assert_python_ok, assert_python_failure
from test import warning_tests
@@ -748,7 +748,19 @@ class EnvironmentVariableTests(BaseTest):
"import sys; sys.stdout.write(str(sys.warnoptions))",
PYTHONWARNINGS="ignore::DeprecationWarning")
self.assertEqual(stdout,
- b"['ignore::UnicodeWarning', 'ignore::DeprecationWarning']")
+ b"['ignore::DeprecationWarning', 'ignore::UnicodeWarning']")
+
+ def test_conflicting_envvar_and_command_line(self):
+ rc, stdout, stderr = assert_python_failure("-Werror::DeprecationWarning", "-c",
+ "import sys, warnings; sys.stdout.write(str(sys.warnoptions)); "
+ "warnings.warn('Message', DeprecationWarning)",
+ PYTHONWARNINGS="default::DeprecationWarning")
+ self.assertEqual(stdout,
+ b"['default::DeprecationWarning', 'error::DeprecationWarning']")
+ self.assertEqual(stderr.splitlines(),
+ [b"Traceback (most recent call last):",
+ b" File \"<string>\", line 1, in <module>",
+ b"DeprecationWarning: Message"])
@unittest.skipUnless(sys.getfilesystemencoding() != 'ascii',
'requires non-ascii filesystemencoding')