--- Lib/test/test_warnings.py
+++ Lib/test/test_warnings.py
@@ -758,9 +758,25 @@
"-c", "import sys; sys.stdout.write(str(sys.warnoptions))"],
stdout=subprocess.PIPE, env=newenv)
self.assertEqual(p.communicate()[0],
- b"['ignore::UnicodeWarning', 'ignore::DeprecationWarning']")
+ b"['ignore::DeprecationWarning', 'ignore::UnicodeWarning']")
self.assertEqual(p.wait(), 0)
+ def test_conflicting_envvar_and_command_line(self):
+ newenv = os.environ.copy()
+ newenv["PYTHONWARNINGS"] = "default::DeprecationWarning"
+ p = subprocess.Popen([sys.executable, "-W" "error::DeprecationWarning",
+ "-c", "import sys, warnings; sys.stdout.write(str(sys.warnoptions));"
+ "warnings.warn('Message', DeprecationWarning)"],
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=newenv)
+ stdout, stderr = p.communicate()
+ self.assertEqual(stdout,
+ b"['default::DeprecationWarning', 'error::DeprecationWarning']")
+ self.assertEqual(stderr,
+ b"Traceback (most recent call last):\n"
+ b" File \"