MCPcopy
hub / github.com/urllib3/urllib3 / pyodide_test

Function pyodide_test

test/contrib/emscripten/test_emscripten.py:35–56  ·  view source on GitHub ↗
(selenium_coverage, host: str, port: int, prefer_jspi: bool)

Source from the content-addressed store, hash-verified

33) -> None:
34 @run_in_pyodide # type: ignore[untyped-decorator]
35 def pyodide_test(selenium_coverage, host: str, port: int, prefer_jspi: bool) -> None: # type: ignore[no-untyped-def]
36 import urllib3.contrib.emscripten.fetch
37 from urllib3.connection import HTTPConnection
38 from urllib3.response import BaseHTTPResponse
39
40 assert urllib3.contrib.emscripten.fetch.has_jspi() == prefer_jspi
41 conn = HTTPConnection(host, port)
42 url = f"http://{host}:{port}/"
43 conn.request("GET", url)
44 response = conn.getresponse()
45 # check methods of response
46 assert isinstance(response, BaseHTTPResponse)
47 assert response.url == url
48 response.url = "http://woo"
49 assert response.url == "http://woo"
50 assert response.connection == conn
51 assert response.retries is None
52 data1 = response.data
53 decoded1 = data1.decode("utf-8")
54 data2 = response.data # check that getting data twice works
55 decoded2 = data2.decode("utf-8")
56 assert decoded1 == decoded2 == "Dummy server!"
57
58 pyodide_test(
59 selenium_coverage,

Callers 15

test_indexFunction · 0.85
test_pool_requestsFunction · 0.85
test_wrong_protocolFunction · 0.85
test_bad_methodFunction · 0.85
test_no_responseFunction · 0.85
test_404Function · 0.85
test_timeout_warningFunction · 0.85
test_index_httpsFunction · 0.85
test_specific_methodFunction · 0.85
test_post_receive_jsonFunction · 0.85

Calls 15

requestMethod · 0.95
getresponseMethod · 0.95
urlopenMethod · 0.95
closeMethod · 0.95
HTTPConnectionClass · 0.90
HTTPSConnectionClass · 0.90
HTTPSConnectionPoolClass · 0.90
HTTPConnectionPoolClass · 0.90
requestFunction · 0.90
_is_node_jsFunction · 0.90
PoolManagerClass · 0.90
should_return_falseFunction · 0.85

Tested by

no test coverage detected