summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKirill Podoprigora <kirill.bast9@mail.ru>2024-04-17 07:25:05 (GMT)
committerGitHub <noreply@github.com>2024-04-17 07:25:05 (GMT)
commit8123c34faa5aab20edc268c7f8a81e6a765af366 (patch)
tree33cebcb930bc6fcee0685a192dc0c75884aabc80
parentc69968ff69b59b27d43708379e4399f424f92075 (diff)
downloadcpython-8123c34faa5aab20edc268c7f8a81e6a765af366.zip
cpython-8123c34faa5aab20edc268c7f8a81e6a765af366.tar.gz
cpython-8123c34faa5aab20edc268c7f8a81e6a765af366.tar.bz2
gh-117923: Catch ``test_webbrowser.test_parse_args_error`` stderr output (#117924)
-rw-r--r--Lib/test/test_webbrowser.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/Lib/test/test_webbrowser.py b/Lib/test/test_webbrowser.py
index 8496652..ae8d776 100644
--- a/Lib/test/test_webbrowser.py
+++ b/Lib/test/test_webbrowser.py
@@ -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 [