|
6 | 6 | import unittest |
7 | 7 | import subprocess |
8 | 8 | from test import support |
| 9 | +from test.script_helper import assert_python_ok |
9 | 10 |
|
10 | 11 | from test import warning_tests |
11 | 12 |
|
@@ -393,6 +394,22 @@ def test_improper_input(self): |
393 | 394 | self.module._setoption('error::Warning::0') |
394 | 395 | self.assertRaises(UserWarning, self.module.warn, 'convert to error') |
395 | 396 |
|
| 397 | + def test_improper_option(self): |
| 398 | + # Same as above, but check that the message is printed out when |
| 399 | + # the interpreter is executed. This also checks that options are |
| 400 | + # actually parsed at all. |
| 401 | + rc, out, err = assert_python_ok("-Wxxx", "-c", "pass") |
| 402 | + self.assertIn(b"Invalid -W option ignored: invalid action: 'xxx'", err) |
| 403 | + |
| 404 | + def test_warnings_bootstrap(self): |
| 405 | + # Check that the warnings module does get loaded when -W<some option> |
| 406 | + # is used (see issue #10372 for an example of silent bootstrap failure). |
| 407 | + rc, out, err = assert_python_ok("-Wi", "-c", |
| 408 | + "import sys; sys.modules['warnings'].warn('foo', RuntimeWarning)") |
| 409 | + # '-Wi' was observed |
| 410 | + self.assertFalse(out.strip()) |
| 411 | + self.assertNotIn(b'RuntimeWarning', err) |
| 412 | + |
396 | 413 | class CWCmdLineTests(BaseTest, WCmdLineTests): |
397 | 414 | module = c_warnings |
398 | 415 |
|
|
0 commit comments