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

Method _test

Lib/test/test_webbrowser.py:37–58  ·  view source on GitHub ↗

Given a web browser instance method name along with arguments and keywords for same (which defaults to the single argument URL), creates a browser instance from the class pointed to by self.browser, calls the indicated instance method with the indicated arguments, and compare

(self, meth, *, args=[URL], kw={}, options, arguments)

Source from the content-addressed store, hash-verified

35class CommandTestMixin:
36
37 def _test(self, meth, *, args=[URL], kw={}, options, arguments):
38 """Given a web browser instance method name along with arguments and
39 keywords for same (which defaults to the single argument URL), creates
40 a browser instance from the class pointed to by self.browser, calls the
41 indicated instance method with the indicated arguments, and compares
42 the resulting options and arguments passed to Popen by the browser
43 instance against the 'options' and 'args' lists. Options are compared
44 in a position independent fashion, and the arguments are compared in
45 sequence order to whatever is left over after removing the options.
46
47 """
48 popen = PopenMock()
49 support.patch(self, subprocess, 'Popen', popen)
50 browser = self.browser_class(name=CMD_NAME)
51 getattr(browser, meth)(*args, **kw)
52 popen_args = subprocess.Popen.call_args[0][0]
53 self.assertEqual(popen_args[0], CMD_NAME)
54 popen_args.pop(0)
55 for option in options:
56 self.assertIn(option, popen_args)
57 popen_args.pop(popen_args.index(option))
58 self.assertEqual(popen_args, arguments)
59
60 def test_reject_dash_prefixes(self):
61 browser = self.browser_class(name=CMD_NAME)

Callers

nothing calls this directly

Calls 5

PopenMockClass · 0.85
assertInMethod · 0.80
assertEqualMethod · 0.45
popMethod · 0.45
indexMethod · 0.45

Tested by

no test coverage detected