forked from pyodide/micropip
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_integration.py
More file actions
106 lines (69 loc) · 2.84 KB
/
Copy pathtest_integration.py
File metadata and controls
106 lines (69 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# Integration tests for micropip
# These test often requires querying to the real packages existing in PyPI,
# to test the micropip's ability to install packages from real world package indexes.
# To prevent sending many requests to remote servers, these tests are disabled by default.
# To run these tests locally, invoke pytest with the `--integration` flag.
import pytest
from pytest_pyodide import run_in_pyodide
def integration_test_only(func):
def wrapper(selenium_standalone_micropip, pytestconfig):
if not pytestconfig.getoption("--integration"):
pytest.skip("Integration tests are skipped. Use --integration to run them.")
func(selenium_standalone_micropip, pytestconfig)
return wrapper
@integration_test_only
def test_integration_install_basic(selenium_standalone_micropip, pytestconfig):
@run_in_pyodide
async def _run(selenium):
import micropip
await micropip.install("snowballstemmer")
import snowballstemmer
snowballstemmer.stemmer("english")
_run(selenium_standalone_micropip)
@integration_test_only
def test_integration_install_no_deps(selenium_standalone_micropip, pytestconfig):
@run_in_pyodide
async def _run(selenium):
import micropip
await micropip.install("pyodide-micropip-test", deps=False)
try:
# pyodide-micropip-test depends on snowballstemmer
import snowballstemmer # noqa: F401
except ModuleNotFoundError:
pass
else:
raise Exception("Should raise!")
_run(selenium_standalone_micropip)
@integration_test_only
def test_integration_list_basic(selenium_standalone_micropip, pytestconfig):
@run_in_pyodide
async def _run(selenium):
import micropip
await micropip.install("snowballstemmer")
packages = micropip.list()
assert "snowballstemmer" in packages
_run(selenium_standalone_micropip)
@integration_test_only
def test_integration_uninstall_basic(selenium_standalone_micropip, pytestconfig):
@run_in_pyodide
async def _run(selenium):
import micropip
await micropip.install("snowballstemmer")
import snowballstemmer
snowballstemmer.stemmer("english")
micropip.uninstall("snowballstemmer")
packages = micropip.list()
assert "snowballstemmer" not in packages
_run(selenium_standalone_micropip)
@integration_test_only
def test_integration_freeze_basic(selenium_standalone_micropip, pytestconfig):
@run_in_pyodide
async def _run(selenium):
import json
import micropip
await micropip.install("snowballstemmer")
import snowballstemmer
snowballstemmer.stemmer("english")
lockfile = micropip.freeze()
assert "snowballstemmer" in json.loads(lockfile)["packages"]
_run(selenium_standalone_micropip)