diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-12-12 21:59:48 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-12 21:59:48 (GMT) |
commit | 747f48e2e92390c44c72f52a1239959601cde157 (patch) | |
tree | 502e53b129aee7a393ca6d05e4f93751919a5e1b /Lib/test/test_warnings | |
parent | b748e3b2586e44bfc7011b601bce9cc6d16d89f1 (diff) | |
download | cpython-747f48e2e92390c44c72f52a1239959601cde157.zip cpython-747f48e2e92390c44c72f52a1239959601cde157.tar.gz cpython-747f48e2e92390c44c72f52a1239959601cde157.tar.bz2 |
bpo-32230: Set sys.warnoptions with -X dev (#4820)
Rather than supporting dev mode directly in the warnings module, this
instead adjusts the initialisation code to add an extra 'default'
entry to sys.warnoptions when dev mode is enabled.
This ensures that dev mode behaves *exactly* as if `-Wdefault` had
been passed on the command line, including in the way it interacts
with `sys.warnoptions`, and with other command line flags like `-bb`.
Fix also bpo-20361: have -b & -bb options take precedence over any
other warnings options.
Patch written by Nick Coghlan, with minor modifications of Victor Stinner.
Diffstat (limited to 'Lib/test/test_warnings')
-rw-r--r-- | Lib/test/test_warnings/__init__.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/Lib/test/test_warnings/__init__.py b/Lib/test/test_warnings/__init__.py index e60bc4d..039c96e 100644 --- a/Lib/test/test_warnings/__init__.py +++ b/Lib/test/test_warnings/__init__.py @@ -1110,20 +1110,23 @@ class EnvironmentVariableTests(BaseTest): def test_single_warning(self): rc, stdout, stderr = assert_python_ok("-c", "import sys; sys.stdout.write(str(sys.warnoptions))", - PYTHONWARNINGS="ignore::DeprecationWarning") + PYTHONWARNINGS="ignore::DeprecationWarning", + PYTHONDEVMODE="") self.assertEqual(stdout, b"['ignore::DeprecationWarning']") def test_comma_separated_warnings(self): rc, stdout, stderr = assert_python_ok("-c", "import sys; sys.stdout.write(str(sys.warnoptions))", - PYTHONWARNINGS="ignore::DeprecationWarning,ignore::UnicodeWarning") + PYTHONWARNINGS="ignore::DeprecationWarning,ignore::UnicodeWarning", + PYTHONDEVMODE="") self.assertEqual(stdout, b"['ignore::DeprecationWarning', 'ignore::UnicodeWarning']") def test_envvar_and_command_line(self): rc, stdout, stderr = assert_python_ok("-Wignore::UnicodeWarning", "-c", "import sys; sys.stdout.write(str(sys.warnoptions))", - PYTHONWARNINGS="ignore::DeprecationWarning") + PYTHONWARNINGS="ignore::DeprecationWarning", + PYTHONDEVMODE="") self.assertEqual(stdout, b"['ignore::DeprecationWarning', 'ignore::UnicodeWarning']") @@ -1131,7 +1134,8 @@ class EnvironmentVariableTests(BaseTest): 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") + PYTHONWARNINGS="default::DeprecationWarning", + PYTHONDEVMODE="") self.assertEqual(stdout, b"['default::DeprecationWarning', 'error::DeprecationWarning']") self.assertEqual(stderr.splitlines(), @@ -1145,7 +1149,8 @@ class EnvironmentVariableTests(BaseTest): rc, stdout, stderr = assert_python_ok("-c", "import sys; sys.stdout.write(str(sys.warnoptions))", PYTHONIOENCODING="utf-8", - PYTHONWARNINGS="ignore:DeprecaciónWarning") + PYTHONWARNINGS="ignore:DeprecaciónWarning", + PYTHONDEVMODE="") self.assertEqual(stdout, "['ignore:DeprecaciónWarning']".encode('utf-8')) |