MCPcopy Index your code
hub / github.com/RustPython/RustPython / _test

Method _test

Lib/test/test_webbrowser.py:260–289  ·  view source on GitHub ↗
(self, meth, **kwargs)

Source from the content-addressed store, hash-verified

258 webbrowser.objc = self.orig_objc
259
260 def _test(self, meth, **kwargs):
261 # The browser always gets focus, there's no concept of separate browser
262 # windows, and there's no API-level control over creating a new tab.
263 # Therefore, all calls to webbrowser are effectively the same.
264 getattr(webbrowser, meth)(URL, **kwargs)
265
266 # The ObjC String version of the URL is created with UTF-8 encoding
267 url_string_args = [
268 "C#NSString",
269 "S#stringWithCString:encoding:",
270 b'https://www.example.com',
271 4,
272 ]
273 # The NSURL version of the URL is created from that string
274 url_obj_args = [
275 "C#NSURL",
276 "S#URLWithString:",
277 self._obj_ref(*url_string_args),
278 ]
279 # The openURL call is invoked on the shared application
280 shared_app_args = ["C#UIApplication", "S#sharedApplication"]
281
282 # Verify that the last call is the one that opens the URL.
283 webbrowser.objc.objc_msgSend.assert_called_with(
284 self._obj_ref(*shared_app_args),
285 "S#openURL:options:completionHandler:",
286 self._obj_ref(*url_obj_args),
287 None,
288 None
289 )
290
291 def test_open(self):
292 self._test('open')

Callers 15

test_openMethod · 0.95
test_open_newMethod · 0.95
test_open_new_tabMethod · 0.95
test_openMethod · 0.45
test_openMethod · 0.45
test_openMethod · 0.45
test_open_newMethod · 0.45
test_open_new_tabMethod · 0.45
test_openMethod · 0.45

Calls 3

_obj_refMethod · 0.95
getattrFunction · 0.85
assert_called_withMethod · 0.80

Tested by

no test coverage detected