Skip unavailable shape-stat kernels

Generated with the assistance of an AI coding tool.
This commit is contained in:
Thomas Krijnen
2026-08-09 11:51:06 +02:00
parent c9c7edd4d6
commit 17c4d8faff
4 changed files with 35 additions and 8 deletions
@@ -14,17 +14,27 @@ test_files = repo_root / "test" / "input" / "tests"
settings = ifcopenshell.geom.settings()
testdata = list(csv.reader((test_files / "data.csv").open(newline="")))[1:]
kernels = [
pytest.param(
kernel,
marks=pytest.mark.skipif(
not ifcopenshell.geom.has_geometry_library(kernel),
reason=f"{kernel} geometry kernel is unavailable",
),
)
for kernel in ("manifold", "opencascade", "cgal")
]
print(testdata)
@pytest.mark.parametrize("fn,area,volume", testdata)
def test_conversion(fn, area, volume):
@pytest.mark.parametrize("kernel", kernels)
def test_conversion(fn, area, volume, kernel):
f = ifcopenshell.open(test_files / fn)
elem = next(inst for inst in f.by_type("IfcElement") if not inst.is_a("IfcOpeningElement"))
for kernel in ("manifold", "opencascade", "cgal"):
shp = ifcopenshell.geom.create_shape(settings, elem, geometry_library=kernel)
if area:
assert pytest.approx(float(area), rel=0.05) == ifcopenshell.util.shape.get_area(shp.geometry)
if volume:
assert pytest.approx(float(volume), rel=0.02) == ifcopenshell.util.shape.get_volume(shp.geometry)
shp = ifcopenshell.geom.create_shape(settings, elem, geometry_library=kernel)
if area:
assert pytest.approx(float(area), rel=0.05) == ifcopenshell.util.shape.get_area(shp.geometry)
if volume:
assert pytest.approx(float(volume), rel=0.02) == ifcopenshell.util.shape.get_volume(shp.geometry)