forked from jupyterlite/xeus-python-kernel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_xeus_python_env.py
63 lines (44 loc) · 1.71 KB
/
test_xeus_python_env.py
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
"""Test creating Python envs for jupyterlite-xeus-python."""
import os
from tempfile import TemporaryDirectory
from pathlib import Path
from jupyterlite_core.app import LiteStatusApp
from jupyterlite_xeus_python.env_build_addon import XeusPythonEnv
def test_python_env():
app = LiteStatusApp(log_level="DEBUG")
app.initialize()
manager = app.lite_manager
addon = XeusPythonEnv(manager)
addon.packages = ["numpy", "ipyleaflet"]
for step in addon.post_build(manager):
pass
# Check env
assert os.path.isdir("/tmp/xeus-python-kernel/envs/xeus-python-kernel")
assert os.path.isfile(
"/tmp/xeus-python-kernel/envs/xeus-python-kernel/bin/xpython_wasm.js"
)
assert os.path.isfile(
"/tmp/xeus-python-kernel/envs/xeus-python-kernel/bin/xpython_wasm.wasm"
)
# Check empack output
assert os.path.isfile(Path(addon.cwd.name) / "empack_env_meta.json")
os.remove(Path(addon.cwd.name) / "empack_env_meta.json")
def test_python_env_from_file_1():
app = LiteStatusApp(log_level="DEBUG")
app.initialize()
manager = app.lite_manager
addon = XeusPythonEnv(manager)
addon.environment_file = "environment-1.yml"
for step in addon.post_build(manager):
pass
# Check env
assert os.path.isdir("/tmp/xeus-python-kernel/envs/xeus-python-kernel-1")
assert os.path.isfile(
"/tmp/xeus-python-kernel/envs/xeus-python-kernel-1/bin/xpython_wasm.js"
)
assert os.path.isfile(
"/tmp/xeus-python-kernel/envs/xeus-python-kernel-1/bin/xpython_wasm.wasm"
)
# Check empack output
assert os.path.isfile(Path(addon.cwd.name) / "empack_env_meta.json")
os.remove(Path(addon.cwd.name) / "empack_env_meta.json")