-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconftest.py
61 lines (47 loc) · 1.51 KB
/
conftest.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
import pytest
import subprocess
from pathlib import Path
import platformdirs
import shutil
from typer.testing import CliRunner
import os
ON_GITHUB_ACTIONS = False
if "GITHUB_ACTION" in os.environ:
ON_GITHUB_ACTIONS = True
@pytest.fixture(scope="session")
def env_prefix(tmp_path_factory):
env_root = tmp_path_factory.mktemp("pytest_code_runner_tests")
env_prefix = Path(env_root) / "testenv"
if env_prefix.exists():
shutil.rmtree(env_prefix)
channels = (
"-c https://repo.mamba.pm/emscripten-forge -c https://repo.mamba.pm/conda-forge"
)
cmd = [
f"""$MAMBA_EXE create {channels} --yes --prefix {env_prefix} --platform=emscripten-32 python numpy pyjs>=2.7.0"""
]
ret = subprocess.run(cmd, shell=True)
# stderr=subprocess.PIPE, stdout=subprocess.PIPE)
returncode = ret.returncode
assert returncode == 0
return env_prefix
# @pytest.fixture(params=["node"]) # , "browser-main", "browser-worker"])
@pytest.fixture(params=["browser-main", "browser-worker"])
def backend_cli_settings(request):
if request.param == "node":
if ON_GITHUB_ACTIONS:
return request.param, [
"--node-binary",
"/home/runner/micromamba-root/envs/dev-env/bin/node",
]
else:
return request.param, []
else:
return request.param, ["--headless"]
@pytest.fixture
def em_work_dir():
return Path("/test")
@pytest.fixture
def runner():
runner = CliRunner(mix_stderr=True)
return runner