forked from scikit-build/scikit-build-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_editable.py
82 lines (67 loc) · 2.62 KB
/
test_editable.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import sys
from pathlib import Path
import pytest
@pytest.mark.compile()
@pytest.mark.configure()
@pytest.mark.integration()
@pytest.mark.parametrize("isolate", [True, False], ids=["isolated", "notisolated"])
@pytest.mark.parametrize(
"package",
[
pytest.param(
True,
id="package",
marks=[pytest.mark.xfail(reason="Only data folders supported currently")],
),
pytest.param(False, id="datafolder"),
],
)
@pytest.mark.usefixtures("navigate_editable")
@pytest.mark.xfail(
sys.version_info[:2] == (3, 9), reason="Python 3.9 not supported yet"
)
def test_navigate_editable(isolated, isolate, package):
isolate_args = ["--no-build-isolation"] if not isolate else []
isolated.install("pip>=23")
if not isolate:
isolated.install("scikit-build-core[pyproject]")
if package:
init_py = Path("python/shared_pkg/data/__init__.py")
init_py.touch()
isolated.install(
"-v", "--config-settings=build-dir=build/{wheel_tag}", *isolate_args, "-e", "."
)
value = isolated.execute("import shared_pkg; shared_pkg.call_c_method()")
assert value == "c_method"
value = isolated.execute("import shared_pkg; shared_pkg.call_py_method()")
assert value == "py_method"
value = isolated.execute("import shared_pkg; shared_pkg.read_py_data_txt()")
assert value == "Some_value_Py"
value = isolated.execute("import shared_pkg; shared_pkg.read_c_generated_txt()")
assert value == "Some_value_C"
@pytest.mark.compile()
@pytest.mark.configure()
@pytest.mark.integration()
@pytest.mark.parametrize("isolate", [True, False], ids=["isolated", "notisolated"])
@pytest.mark.usefixtures("navigate_editable")
def test_navigate_editable2(isolated, isolate):
isolate_args = ["--no-build-isolation"] if not isolate else []
isolated.install("pip>=23")
if not isolate:
isolated.install("scikit-build-core[pyproject]")
isolated.install(
"-v", "--config-settings=build-dir=build/{wheel_tag}", *isolate_args, "-e", "."
)
# Navigate from py_package to py_package
value = isolated.execute("import py_pkg.py1_pkg; py_pkg.py1_pkg.py2_method_a()")
assert value == "py2_method_a"
# Navigate from py_package.py_module to py_package
value = isolated.execute(
"import py_pkg.py1_pkg.py1_module; py_pkg.py1_pkg.py1_module.py2_method_b()"
)
assert value == "py2_method_b"
# Navigate from py_package.py_module to py_package.py_module
value = isolated.execute(
"import py_pkg.py1_pkg.py1_module; py_pkg.py1_pkg.py1_module.py2_method_c()"
)
assert value == "py2_method_c"