From 7c66319edcbeb3d1590e1c2397efea3171623be2 Mon Sep 17 00:00:00 2001 From: Ezio Melotti Date: Sun, 18 Nov 2012 13:55:52 +0200 Subject: #16306: Fix multiple error messages when unknown command line parameters where passed to the interpreter. Patch by Hieu Nguyen. --- Lib/test/test_cmd_line.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'Lib/test') diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py index 7d039ee00e..d8f244353c 100644 --- a/Lib/test/test_cmd_line.py +++ b/Lib/test/test_cmd_line.py @@ -7,7 +7,8 @@ import os import sys import subprocess import tempfile -from test.script_helper import spawn_python, kill_python, assert_python_ok, assert_python_failure +from test.script_helper import (spawn_python, kill_python, assert_python_ok, + assert_python_failure) # XXX (ncoghlan): Move to script_helper and make consistent with run_python @@ -376,6 +377,12 @@ class CmdLineTest(unittest.TestCase): assert_python_ok(filename) + def test_unknown_options(self): + rc, out, err = assert_python_failure('-z', __cleanenv=True) + self.assertIn(b'Unknown option', err) + self.assertEqual(err.splitlines().count(b'Unknown option: -z'), 1) + self.assertEqual(b'', out) + def test_main(): test.support.run_unittest(CmdLineTest) test.support.reap_children() -- cgit v1.2.1