summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2020-05-06 13:43:09 (GMT)
committerGitHub <noreply@github.com>2020-05-06 13:43:09 (GMT)
commitbce4ddafdd188cc6deb1584728b67b9e149ca6a4 (patch)
tree1d8aa1504c397e86ba73b8ea7d2f410bea9ab275 /Lib/test
parenta32587a60da5939a3932bb30432d2bdd3d6203d4 (diff)
downloadcpython-bce4ddafdd188cc6deb1584728b67b9e149ca6a4.zip
cpython-bce4ddafdd188cc6deb1584728b67b9e149ca6a4.tar.gz
cpython-bce4ddafdd188cc6deb1584728b67b9e149ca6a4.tar.bz2
bpo-40527: Fix command line argument parsing (GH-19955)
(cherry picked from commit 2668a9a5aa506a048aef7b4881c8dcf6b81c6870) Co-authored-by: Victor Stinner <vstinner@python.org>
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_cmd_line.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py
index 497bfa9..5fc5bff 100644
--- a/Lib/test/test_cmd_line.py
+++ b/Lib/test/test_cmd_line.py
@@ -740,6 +740,17 @@ class CmdLineTest(unittest.TestCase):
self.assertEqual(proc.returncode, 0, proc)
self.assertEqual(proc.stdout.strip(), b'0')
+ def test_parsing_error(self):
+ args = [sys.executable, '-I', '--unknown-option']
+ proc = subprocess.run(args,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ text=True)
+ err_msg = "unknown option --unknown-option\nusage: "
+ self.assertTrue(proc.stderr.startswith(err_msg), proc.stderr)
+ self.assertNotEqual(proc.returncode, 0)
+
+
@unittest.skipIf(interpreter_requires_environment(),
'Cannot run -I tests when PYTHON env vars are required.')
class IgnoreEnvironmentTest(unittest.TestCase):