-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathconftest.py
More file actions
66 lines (52 loc) · 1.69 KB
/
conftest.py
File metadata and controls
66 lines (52 loc) · 1.69 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
import pytest
import subprocess
from pathlib import Path
import platformdirs
import shutil
from typer.testing import CliRunner
import os
# @pytest.fixture(scope="session")
# def session_temp_path(tmp_path_factory):
# return tmp_path_factory.mktemp()
ON_GITHUB_ACTIONS = False
if "GITHUB_ACTION" in os.environ:
ON_GITHUB_ACTIONS = True
@pytest.fixture(scope="session")
def env_prefix():
env_root = Path(platformdirs.user_data_dir("pytest_code_runner_tests"))
env_root.mkdir(exist_ok=True, parents=True)
env_prefix = Path(env_root) / "testenv"
if env_prefix.exists():
shutil.rmtree(env_prefix)
print("prefix", 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 """
]
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