https://github.com/python/cpython/commit/8123c34faa5aab20edc268c7f8a81e6a765af366
commit: 8123c34faa5aab20edc268c7f8a81e6a765af366
branch: main
author: Kirill Podoprigora <[email protected]>
committer: sobolevn <[email protected]>
date: 2024-04-17T10:25:05+03:00
summary:

gh-117923: Catch ``test_webbrowser.test_parse_args_error`` stderr output 
(#117924)

files:
M Lib/test/test_webbrowser.py

diff --git a/Lib/test/test_webbrowser.py b/Lib/test/test_webbrowser.py
index 849665294c3dfa..ae8d776e8413ff 100644
--- a/Lib/test/test_webbrowser.py
+++ b/Lib/test/test_webbrowser.py
@@ -461,11 +461,23 @@ def test_parse_args_error(self):
             "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 [

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to