|
13 | 13 | from test.support import is_apple_mobile |
14 | 14 | from test.support import os_helper |
15 | 15 | from test.support import requires_subprocess |
| 16 | +from test.support import script_helper |
16 | 17 | from test.support import threading_helper |
17 | 18 | from unittest import mock |
18 | 19 |
|
@@ -679,5 +680,25 @@ def test_main(self): |
679 | 680 | mock_open.assert_called_once_with(expected_url, expected_new_win) |
680 | 681 |
|
681 | 682 |
|
| 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 | + |
682 | 703 | if __name__ == '__main__': |
683 | 704 | unittest.main() |
0 commit comments