summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_cmd_line.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_cmd_line.py')
-rw-r--r--Lib/test/test_cmd_line.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py
index b803046..12f26d9 100644
--- a/Lib/test/test_cmd_line.py
+++ b/Lib/test/test_cmd_line.py
@@ -116,14 +116,24 @@ class CmdLineTest(unittest.TestCase):
print >>script, "del sys.modules['__main__']"
assert_python_ok(filename)
-
def test_unknown_options(self):
- # Add "without='-E'" to prevent _assert_python append env_vars -E
- # which changes the output of stderr
+ 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', err)
+ 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.test_support.run_unittest(CmdLineTest)