Skip to content

Commit 8ece4a2

Browse files
committed
gh-131178: Add tests for the webbrowser command-line interface
1 parent f316080 commit 8ece4a2

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

‎Lib/test/test_webbrowser.py‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from test.support import is_apple_mobile
1414
from test.support import os_helper
1515
from test.support import requires_subprocess
16+
from test.support import script_helper
1617
from test.support import threading_helper
1718
from unittest import mock
1819

@@ -679,5 +680,25 @@ def test_main(self):
679680
mock_open.assert_called_once_with(expected_url, expected_new_win)
680681

681682

683+
@requires_subprocess()
684+
class CommandLineSubprocessTest(unittest.TestCase):
685+
def test_help(self):
686+
_, stdout, stderr = script_helper.assert_python_ok(
687+
'-m', 'webbrowser', '--help',
688+
)
689+
self.assertIn(b'usage:', stdout)
690+
self.assertIn(b'--new-window', stdout)
691+
self.assertIn(b'--new-tab', stdout)
692+
self.assertEqual(stderr, b'')
693+
694+
def test_conflicting_options(self):
695+
rc, stdout, stderr = script_helper.assert_python_failure(
696+
'-m', 'webbrowser', '-n', '-t', URL, PYTHON_COLORS='0',
697+
)
698+
self.assertEqual(rc, 2)
699+
self.assertEqual(stdout, b'')
700+
self.assertIn(b'-t/--new-tab: not allowed with argument -n/--new-window', stderr)
701+
702+
682703
if __name__ == '__main__':
683704
unittest.main()

0 commit comments

Comments
 (0)