]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-117923: Catch ``test_webbrowser.test_parse_args_error`` stderr output (#117924)
authorKirill Podoprigora <kirill.bast9@mail.ru>
Wed, 17 Apr 2024 07:25:05 +0000 (10:25 +0300)
committerGitHub <noreply@github.com>
Wed, 17 Apr 2024 07:25:05 +0000 (10:25 +0300)
Lib/test/test_webbrowser.py

index 849665294c3dfa09f073232c9e3a55314bedf273..ae8d776e8413ffcd870601994def48d69bab8b16 100644 (file)
@@ -461,11 +461,23 @@ class CliTest(unittest.TestCase):
             "https://example.com --new-window --new-tab",
             "https://example.com -n --new-tab",
             "https://example.com --new-window -t",
-            # Ensure ambiguous shortening fails
-            "https://example.com --new",
         ]:
+            with support.captured_stderr() as stderr:
+                with self.assertRaises(SystemExit):
+                    webbrowser.parse_args(shlex.split(command))
+                self.assertIn(
+                    'error: argument -t/--new-tab: not allowed with argument -n/--new-window',
+                    stderr.getvalue(),
+                )
+
+        # Ensure ambiguous shortening fails
+        with support.captured_stderr() as stderr:
             with self.assertRaises(SystemExit):
-                webbrowser.parse_args(shlex.split(command))
+                webbrowser.parse_args(shlex.split("https://example.com --new"))
+            self.assertIn(
+                'error: ambiguous option: --new could match --new-window, --new-tab',
+                stderr.getvalue()
+            )
 
     def test_main(self):
         for command, expected_url, expected_new_win in [