diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2010-11-10 14:01:16 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-11-10 14:01:16 (GMT) |
commit | cb4f9298123f1cfbbe1bdeddfbbadd2aa448140b (patch) | |
tree | 8a6afeea1631cc310056f183984f0298c0dc3db2 /Lib/test/test_warnings.py | |
parent | 0a69b856d56860e2dce0ae58e65de57c58a95763 (diff) | |
download | cpython-cb4f9298123f1cfbbe1bdeddfbbadd2aa448140b.zip cpython-cb4f9298123f1cfbbe1bdeddfbbadd2aa448140b.tar.gz cpython-cb4f9298123f1cfbbe1bdeddfbbadd2aa448140b.tar.bz2 |
I'm only backporting the tests (which run fine), as well as
a shortened version of Lib/test/script_helper.py.
Merged revisions 86395 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r86395 | antoine.pitrou | 2010-11-10 14:55:25 +0100 (mer., 10 nov. 2010) | 4 lines
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.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_warnings.py b/Lib/test/test_warnings.py index 85b5cad..33c4e65 100644 --- a/Lib/test/test_warnings.py +++ b/Lib/test/test_warnings.py @@ -7,6 +7,7 @@ import unittest import tempfile import subprocess from test import support +from test.script_helper import assert_python_ok from test import warning_tests @@ -394,6 +395,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 |