Skip to content

Commit 232c979

Browse files
authored
CI Enable node test [full build] (#170)
1 parent 6270d1d commit 232c979

File tree

5 files changed

+67
-131
lines changed

5 files changed

+67
-131
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ jobs:
314314
test-config: [
315315
{runner: selenium, runtime: chrome, runtime-version: 134 },
316316
{runner: selenium, runtime: firefox, runtime-version: "136.0" },
317+
{runner: selenium, runtime: node, runtime-version: "24" },
317318
]
318319

319320
steps:

packages/aiohttp/test_aiohttp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ async def aiohttp_test_helper(selenium, patch, base_url, lock_data):
2222
assert body == expected
2323

2424

25+
@pytest.mark.xfail_browsers(node="Not available")
2526
def test_aiohttp(selenium):
2627
patch = (Path(__file__).parent / "aiohttp_patch.py").read_text()
2728
dist_dir = cast(str, pytest.pyodide_dist_dir) # type:ignore[attr-defined]

packages/micropip/test_micropip.py

Lines changed: 58 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
from tempfile import TemporaryDirectory
44

55
import pytest
6-
from pytest_pyodide import run_in_pyodide, spawn_web_server
7-
8-
from conftest import package_is_built
6+
from pytest_pyodide import run_in_pyodide
97

108
cpver = f"cp{sys.version_info.major}{sys.version_info.minor}"
119

1210

1311
WHEEL_BASE = None
12+
SNOWBALL_WHEEL = (
13+
Path(__file__).parent / "test" / "snowballstemmer-2.0.0-py2.py3-none-any.whl"
14+
)
1415

1516

1617
@pytest.fixture
@@ -43,9 +44,6 @@ def selenium_standalone_micropip(selenium_standalone):
4344
yield selenium_standalone
4445

4546

46-
SNOWBALL_WHEEL = "snowballstemmer-2.0.0-py2.py3-none-any.whl"
47-
48-
4947
def test_install_simple(selenium_standalone_micropip):
5048
selenium = selenium_standalone_micropip
5149
assert selenium.run_js(
@@ -65,38 +63,38 @@ def test_install_simple(selenium_standalone_micropip):
6563
) == ["go", "go", "goe", "gone"]
6664

6765

68-
@pytest.mark.parametrize("base_url", ["'{base_url}'", "'.'"])
69-
def test_install_custom_url(selenium_standalone_micropip, base_url):
66+
def test_install_custom_url(selenium_standalone_micropip, httpserver):
7067
selenium = selenium_standalone_micropip
7168

72-
with spawn_web_server(Path(__file__).parent / "test") as server:
73-
server_hostname, server_port, _ = server
74-
base_url = f"http://{server_hostname}:{server_port}/"
75-
url = base_url + SNOWBALL_WHEEL
69+
httpserver.expect_oneshot_request(f"/{SNOWBALL_WHEEL.name}").respond_with_data(
70+
SNOWBALL_WHEEL.read_bytes(),
71+
content_type="application/zip",
72+
headers={"Access-Control-Allow-Origin": "*"},
73+
status=200,
74+
)
75+
url = httpserver.url_for(SNOWBALL_WHEEL.name)
7676

77-
selenium.run_js(
78-
f"""
79-
await pyodide.runPythonAsync(`
80-
import micropip
81-
await micropip.install('{url}')
82-
import snowballstemmer
83-
`);
84-
"""
85-
)
77+
selenium.run_js(
78+
f"""
79+
await pyodide.runPythonAsync(`
80+
import micropip
81+
await micropip.install('{url}')
82+
import snowballstemmer
83+
`);
84+
"""
85+
)
8686

8787

8888
@pytest.mark.xfail_browsers(chrome="node only", firefox="node only")
8989
def test_install_file_protocol_node(selenium_standalone_micropip):
9090
selenium = selenium_standalone_micropip
91-
from conftest import DIST_PATH
9291

93-
pyparsing_wheel_name = list(DIST_PATH.glob("pyparsing*.whl"))[0].name
9492
selenium.run_js(
9593
f"""
9694
await pyodide.runPythonAsync(`
9795
import micropip
98-
await micropip.install('file:{pyparsing_wheel_name}')
99-
import pyparsing
96+
await micropip.install('file:{SNOWBALL_WHEEL.as_posix()}')
97+
import snowballstemmer
10098
`);
10199
"""
102100
)
@@ -146,114 +144,52 @@ def test_install_different_version2(selenium_standalone_micropip):
146144
)
147145

148146

149-
@pytest.mark.parametrize("jinja2", ["jinja2", "Jinja2"])
150-
def test_install_mixed_case2(selenium_standalone_micropip, jinja2):
151-
selenium = selenium_standalone_micropip
152-
selenium.run_js(
153-
f"""
154-
await pyodide.loadPackage("micropip");
155-
await pyodide.runPythonAsync(`
156-
import micropip
157-
await micropip.install("{jinja2}")
158-
import jinja2
159-
`);
160-
"""
147+
def test_list_load_package_from_url(selenium_standalone_micropip, httpserver):
148+
httpserver.expect_oneshot_request(f"/{SNOWBALL_WHEEL.name}").respond_with_data(
149+
SNOWBALL_WHEEL.read_bytes(),
150+
content_type="application/zip",
151+
headers={"Access-Control-Allow-Origin": "*"},
152+
status=200,
161153
)
154+
url = httpserver.url_for(SNOWBALL_WHEEL.name)
162155

163-
164-
def test_list_load_package_from_url(selenium_standalone_micropip):
165-
with spawn_web_server(Path(__file__).parent / "test") as server:
166-
server_hostname, server_port, _ = server
167-
base_url = f"http://{server_hostname}:{server_port}/"
168-
url = base_url + SNOWBALL_WHEEL
169-
170-
selenium = selenium_standalone_micropip
171-
selenium.run_js(
172-
f"""
173-
await pyodide.loadPackage({url!r});
174-
await pyodide.runPythonAsync(`
175-
import micropip
176-
assert "snowballstemmer" in micropip.list()
177-
`);
178-
"""
179-
)
180-
181-
182-
def test_list_pyodide_package(selenium_standalone_micropip):
183156
selenium = selenium_standalone_micropip
184157
selenium.run_js(
185-
"""
186-
await pyodide.runPythonAsync(`
187-
import micropip
188-
await micropip.install(
189-
"regex"
190-
);
191-
`);
192-
"""
193-
)
194-
selenium.run_js(
195-
"""
158+
f"""
159+
await pyodide.loadPackage({url!r});
196160
await pyodide.runPythonAsync(`
197161
import micropip
198-
pkgs = micropip.list()
199-
assert "regex" in pkgs
200-
assert pkgs["regex"].source.lower() == "pyodide"
162+
assert "snowballstemmer" in micropip.list()
201163
`);
202164
"""
203165
)
204166

205167

206-
def test_list_loaded_from_js(selenium_standalone_micropip):
207-
selenium = selenium_standalone_micropip
208-
selenium.run_js(
209-
"""
210-
await pyodide.loadPackage("regex");
211-
await pyodide.runPythonAsync(`
212-
import micropip
213-
pkgs = micropip.list()
214-
assert "regex" in pkgs
215-
assert pkgs["regex"].source.lower() == "pyodide"
216-
`);
217-
"""
168+
def test_emfs(selenium_standalone_micropip, httpserver):
169+
httpserver.expect_oneshot_request(f"/{SNOWBALL_WHEEL.name}").respond_with_data(
170+
SNOWBALL_WHEEL.read_bytes(),
171+
content_type="application/zip",
172+
headers={"Access-Control-Allow-Origin": "*"},
173+
status=200,
218174
)
175+
url = httpserver.url_for(f"/{SNOWBALL_WHEEL.name}")
219176

220-
221-
def test_emfs(selenium_standalone_micropip):
222-
with spawn_web_server(Path(__file__).parent / "test") as server:
223-
server_hostname, server_port, _ = server
224-
url = f"http://{server_hostname}:{server_port}/"
225-
226-
@run_in_pyodide(packages=["micropip"])
227-
async def run_test(selenium, url, wheel_name):
228-
import micropip
229-
from pyodide.http import pyfetch
230-
231-
resp = await pyfetch(url + wheel_name)
232-
await resp._into_file(open(wheel_name, "wb"))
233-
await micropip.install("emfs:" + wheel_name)
234-
import snowballstemmer
235-
236-
stemmer = snowballstemmer.stemmer("english")
237-
assert stemmer.stemWords("go going goes gone".split()) == [
238-
"go",
239-
"go",
240-
"goe",
241-
"gone",
242-
]
243-
244-
run_test(selenium_standalone_micropip, url, SNOWBALL_WHEEL)
245-
246-
247-
def test_install_non_normalized_package(selenium_standalone_micropip):
248-
if not package_is_built("ruamel-yaml"):
249-
pytest.skip("ruamel.yaml not built")
250-
251-
selenium = selenium_standalone_micropip
252-
253-
selenium.run_async(
254-
"""
177+
@run_in_pyodide(packages=["micropip"])
178+
async def run_test(selenium, url, wheel_name):
255179
import micropip
256-
await micropip.install("ruamel.yaml")
257-
import ruamel.yaml
258-
"""
259-
)
180+
from pyodide.http import pyfetch
181+
182+
resp = await pyfetch(url)
183+
await resp._into_file(open(wheel_name, "wb"))
184+
await micropip.install("emfs:" + wheel_name)
185+
import snowballstemmer
186+
187+
stemmer = snowballstemmer.stemmer("english")
188+
assert stemmer.stemWords("go going goes gone".split()) == [
189+
"go",
190+
"go",
191+
"goe",
192+
"gone",
193+
]
194+
195+
run_test(selenium_standalone_micropip, url, SNOWBALL_WHEEL.name)

packages/python-flint/test_python_flint.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,7 @@ def test_python_flint(selenium):
1414
assert a.gcd(a * b) == a
1515

1616

17-
@pytest.mark.xfail_browsers(firefox="times out", chrome="times out")
18-
@run_in_pyodide(packages=["python-flint"])
19-
def test_python_flint_tests(selenium):
20-
from flint.test.__main__ import main
21-
22-
main("--tests", "--verbose")
23-
24-
25-
@pytest.mark.xfail_browsers(firefox="times out")
17+
@pytest.mark.xfail_browsers(firefox="times out", node="times out")
2618
@pytest.mark.parametrize(
2719
"module",
2820
[

packages/sisl/test_sisl.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from pytest_pyodide import run_in_pyodide
33

44

5+
@pytest.mark.driver_timeout(60)
56
@pytest.mark.xfail_browsers(firefox="Too slow")
67
@run_in_pyodide(packages=["sisl-tests", "pytest"])
78
def test_load_sisl(selenium):
@@ -11,6 +12,7 @@ def test_load_sisl(selenium):
1112
pass
1213

1314

15+
@pytest.mark.driver_timeout(60)
1416
@pytest.mark.xfail_browsers(firefox="Too slow")
1517
@run_in_pyodide(packages=["sisl-tests", "pytest"])
1618
def test_nodes(selenium):
@@ -19,6 +21,7 @@ def test_nodes(selenium):
1921
pytest.main(["--pyargs", "sisl.nodes"])
2022

2123

24+
@pytest.mark.driver_timeout(60)
2225
@pytest.mark.xfail_browsers(firefox="Too slow")
2326
@run_in_pyodide(packages=["sisl-tests", "pytest"])
2427
def test_geom(selenium):
@@ -27,6 +30,7 @@ def test_geom(selenium):
2730
pytest.main(["--pyargs", "sisl.geom"])
2831

2932

33+
@pytest.mark.driver_timeout(60)
3034
@pytest.mark.xfail_browsers(firefox="Too slow")
3135
@run_in_pyodide(packages=["sisl-tests", "pytest"])
3236
def test_linalg(selenium):
@@ -35,6 +39,7 @@ def test_linalg(selenium):
3539
pytest.main(["--pyargs", "sisl.linalg"])
3640

3741

42+
@pytest.mark.driver_timeout(60)
3843
@pytest.mark.xfail_browsers(firefox="Too slow")
3944
@run_in_pyodide(packages=["sisl-tests", "pytest"])
4045
def test_sparse(selenium):
@@ -43,6 +48,7 @@ def test_sparse(selenium):
4348
pytest.main(["--pyargs", "sisl.tests.test_sparse"])
4449

4550

51+
@pytest.mark.driver_timeout(60)
4652
@pytest.mark.xfail_browsers(firefox="Too slow")
4753
@run_in_pyodide(packages=["sisl-tests", "pytest"])
4854
def test_physics_sparse(selenium):

0 commit comments

Comments
 (0)