summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_warnings.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-11-10 13:55:25 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-11-10 13:55:25 (GMT)
commitcf9f98034a6bc7c55486042da1867447cfd2f0b5 (patch)
treec1f4e79be6317a8ec7381c68cb3d43d5c07cfad2 /Lib/test/test_warnings.py
parent81c87c5e9a81728f4c7b022e3786ce11d53ed3c9 (diff)
downloadcpython-cf9f98034a6bc7c55486042da1867447cfd2f0b5.zip
cpython-cf9f98034a6bc7c55486042da1867447cfd2f0b5.tar.gz
cpython-cf9f98034a6bc7c55486042da1867447cfd2f0b5.tar.bz2
Issue #10372: Import the warnings module only after the IO library is
initialized, so as to avoid bootstrap issues with the '-W' option.
Diffstat (limited to 'Lib/test/test_warnings.py')
-rw-r--r--Lib/test/test_warnings.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_warnings.py b/Lib/test/test_warnings.py
index 52b9dbe..111ff79 100644
--- a/Lib/test/test_warnings.py
+++ b/Lib/test/test_warnings.py
@@ -6,6 +6,7 @@ import sys
import unittest
import subprocess
from test import support
+from test.script_helper import assert_python_ok
from test import warning_tests
@@ -393,6 +394,22 @@ class WCmdLineTests(unittest.TestCase):
self.module._setoption('error::Warning::0')
self.assertRaises(UserWarning, self.module.warn, 'convert to error')
+ def test_improper_option(self):
+ # Same as above, but check that the message is printed out when
+ # the interpreter is executed. This also checks that options are
+ # actually parsed at all.
+ rc, out, err = assert_python_ok("-Wxxx", "-c", "pass")
+ self.assertIn(b"Invalid -W option ignored: invalid action: 'xxx'", err)
+
+ def test_warnings_bootstrap(self):
+ # Check that the warnings module does get loaded when -W<some option>
+ # is used (see issue #10372 for an example of silent bootstrap failure).
+ rc, out, err = assert_python_ok("-Wi", "-c",
+ "import sys; sys.modules['warnings'].warn('foo', RuntimeWarning)")
+ # '-Wi' was observed
+ self.assertFalse(out.strip())
+ self.assertNotIn(b'RuntimeWarning', err)
+
class CWCmdLineTests(BaseTest, WCmdLineTests):
module = c_warnings