diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2012-11-23 17:01:42 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2012-11-23 17:01:42 (GMT) |
commit | 8b9a8f3c98d02c9e9721570428aa8420568b8f02 (patch) | |
tree | 6270f6d9a7480c83ec4de9d6fc5a71046b68674c /Lib/test/test_cmd_line.py | |
parent | 9f8c2194c20947a890b3d34e5f4ac185afa4d0fb (diff) | |
parent | 8a6d1fed416fb84c74fa4fd948b3a2a395335278 (diff) | |
download | cpython-8b9a8f3c98d02c9e9721570428aa8420568b8f02.zip cpython-8b9a8f3c98d02c9e9721570428aa8420568b8f02.tar.gz cpython-8b9a8f3c98d02c9e9721570428aa8420568b8f02.tar.bz2 |
#16306: merge with 3.3.
Diffstat (limited to 'Lib/test/test_cmd_line.py')
-rw-r--r-- | Lib/test/test_cmd_line.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py index aa99c15..4e56cd1 100644 --- a/Lib/test/test_cmd_line.py +++ b/Lib/test/test_cmd_line.py @@ -387,12 +387,24 @@ class CmdLineTest(unittest.TestCase): print("del sys.modules['__main__']", file=script) assert_python_ok(filename) - def test_unknown_options(self): - rc, out, err = assert_python_failure('-z', __cleanenv=True) - self.assertIn(b'Unknown option', err) + rc, out, err = assert_python_failure('-E', '-z') + self.assertIn(b'Unknown option: -z', err) + self.assertEqual(err.splitlines().count(b'Unknown option: -z'), 1) + self.assertEqual(b'', out) + # Add "without='-E'" to prevent _assert_python to append -E + # to env_vars and change the output of stderr + rc, out, err = assert_python_failure('-z', without='-E') + self.assertIn(b'Unknown option: -z', err) self.assertEqual(err.splitlines().count(b'Unknown option: -z'), 1) self.assertEqual(b'', out) + rc, out, err = assert_python_failure('-a', '-z', without='-E') + self.assertIn(b'Unknown option: -a', err) + # only the first unknown option is reported + self.assertNotIn(b'Unknown option: -z', err) + self.assertEqual(err.splitlines().count(b'Unknown option: -a'), 1) + self.assertEqual(b'', out) + def test_main(): test.support.run_unittest(CmdLineTest) |