| 673 | |
| 674 | |
| 675 | def 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 | |
| 704 | def test_open_close( |