MCPcopy Index your code
hub / github.com/python/cpython / test_main

Method test_main

Lib/test/test_webbrowser.py:568–588  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

566 )
567
568 def test_main(self):
569 for command, expected_url, expected_new_win in [
570 # No optional arguments
571 ("https://example.com", "https://example.com", 0),
572 # Each optional argument
573 ("https://example.com -n", "https://example.com", 1),
574 ("-n https://example.com", "https://example.com", 1),
575 ("https://example.com -t", "https://example.com", 2),
576 ("-t https://example.com", "https://example.com", 2),
577 # Long form
578 ("https://example.com --new-window", "https://example.com", 1),
579 ("--new-window https://example.com", "https://example.com", 1),
580 ("https://example.com --new-tab", "https://example.com", 2),
581 ("--new-tab https://example.com", "https://example.com", 2),
582 ]:
583 with (
584 mock.patch("webbrowser.open", return_value=None) as mock_open,
585 mock.patch("builtins.print", return_value=None),
586 ):
587 webbrowser.main(shlex.split(command))
588 mock_open.assert_called_once_with(expected_url, expected_new_win)
589
590
591if __name__ == '__main__':

Callers 1

runtestFunction · 0.45

Calls 3

mainMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected