MCPcopy
hub / github.com/urllib3/urllib3 / test_requests_with_micropip

Function test_requests_with_micropip

test/contrib/emscripten/test_emscripten.py:675–701  ·  view source on GitHub ↗
(
    selenium_coverage: typing.Any,
    testserver_http: PyodideServerInfo,
)

Source from the content-addressed store, hash-verified

673
674
675def test_requests_with_micropip(
676 selenium_coverage: typing.Any,
677 testserver_http: PyodideServerInfo,
678) -> None:
679 @run_in_pyodide(packages=["micropip"]) # type: ignore[untyped-decorator]
680 async def test_fn(
681 selenium_coverage: typing.Any, http_host: str, http_port: int, https_port: int
682 ) -> None:
683 import micropip # type: ignore[import-not-found]
684
685 await micropip.install("requests")
686 import requests
687
688 r = requests.get(f"http://{http_host}:{http_port}/")
689 assert r.status_code == 200
690 assert r.text == "Dummy server!"
691 json_data = {"woo": "yay"}
692 # try posting some json with requests on https
693 r = requests.post(f"https://{http_host}:{https_port}/echo_json", json=json_data)
694 assert r.json() == json_data
695
696 test_fn(
697 selenium_coverage,
698 testserver_http.http_host,
699 testserver_http.http_port,
700 testserver_http.https_port,
701 )
702
703
704def test_open_close(

Callers

nothing calls this directly

Calls 1

test_fnFunction · 0.85

Tested by

no test coverage detected