-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_structs.py
More file actions
26 lines (22 loc) · 851 Bytes
/
test_structs.py
File metadata and controls
26 lines (22 loc) · 851 Bytes
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
import pytest
from pydantic import ValidationError
from hatch_cpp.structs import HatchCppLibrary, HatchCppPlatform
class TestStructs:
def test_validate_py_limited_api(self):
with pytest.raises(ValidationError):
library = HatchCppLibrary(
name="test",
sources=["test.cpp"],
py_limited_api="42",
)
library = HatchCppLibrary(
name="test",
sources=["test.cpp"],
py_limited_api="cp39",
)
assert library.py_limited_api == "cp39"
platform = HatchCppPlatform.default()
flags = platform.get_compile_flags(library)
assert "-DPy_LIMITED_API=0x030900f0" in flags or "/DPy_LIMITED_API=0x030900f0" in flags
with pytest.raises(ValidationError):
library.binding = "pybind11"