From 3f018a419514d4f06c0a24ce82135caa91891bc7 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Tue, 17 Oct 2023 15:36:10 +0500 Subject: [PATCH] localize mathutils dependency in tests #3895 replaced shapebuilder with general ifcopenshell code in `test_add_boolean` (the only place besides `test_shape_builder` where it was used), that way mathutils dependency in tests is localized only to `test_shape_builder.py`. added test-safe option to makefile, so github workflow would ignore `test_shape_builder` tests for now and it wouldn't interrupt the entire workflow --- .github/workflows/ci-py-only.yml | 3 +-- .github/workflows/ci.yml | 3 +-- src/ifcopenshell-python/Makefile | 6 ++++++ .../test/api/geometry/test_add_boolean.py | 21 +++++++++++++------ 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci-py-only.yml b/.github/workflows/ci-py-only.yml index 6b13686022..08d29461b0 100644 --- a/.github/workflows/ci-py-only.yml +++ b/.github/workflows/ci-py-only.yml @@ -88,7 +88,6 @@ jobs: sudo /usr/bin/python -m pip install networkx sudo /usr/bin/python -m pip install tabulate sudo /usr/bin/python -m pip install python-dateutil - sudo /usr/bin/python -m pip install mathutils - name: Test run: | @@ -96,4 +95,4 @@ jobs: sudo /usr/bin/python tests.py cd ../src/ifcopenshell-python mv ifcopenshell ifcopenshell-local # Force testing on installed module - make test + make test-safe diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 06c247f325..6b8026111b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -114,7 +114,6 @@ jobs: sudo /usr/bin/python -m pip install https://github.com/Andrej730/aud/archive/refs/heads/master-reduced-size.zip sudo /usr/bin/python -m pip install tabulate sudo /usr/bin/python -m pip install python-dateutil - sudo /usr/bin/python -m pip install mathutils - name: Test run: | @@ -122,4 +121,4 @@ jobs: sudo /usr/bin/python tests.py cd ../src/ifcopenshell-python mv ifcopenshell ifcopenshell-local # Force testing on installed module - make test + make test-safe diff --git a/src/ifcopenshell-python/Makefile b/src/ifcopenshell-python/Makefile index 105f0faf28..f4b0229617 100644 --- a/src/ifcopenshell-python/Makefile +++ b/src/ifcopenshell-python/Makefile @@ -68,6 +68,12 @@ endif test: pytest -p no:pytest-blender test +# safe version of tests without mathutils dependency +# for tests to work for github workflow with python <3.10 #3895 +.PHONY: test-safe +test-safe: + pytest -p no:pytest-blender test --ignore=test/util/test_shape_builder.py + .PHONY: build-ids-docs build-ids-docs: mkdir -p test/build diff --git a/src/ifcopenshell-python/test/api/geometry/test_add_boolean.py b/src/ifcopenshell-python/test/api/geometry/test_add_boolean.py index 041e6c1980..62d7d33a82 100644 --- a/src/ifcopenshell-python/test/api/geometry/test_add_boolean.py +++ b/src/ifcopenshell-python/test/api/geometry/test_add_boolean.py @@ -19,11 +19,10 @@ import test.bootstrap import ifcopenshell.api import numpy as np -from ifcopenshell.util.shape_builder import ShapeBuilder class TestAddBoolean(test.bootstrap.IFC4): - def test_returning_ifc_boolean_result(self): + def test_returning_ifc_boolean_clipping_result(self): ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject") model = ifcopenshell.api.run("context.add_context", self.file, context_type="Model") body = ifcopenshell.api.run( @@ -36,11 +35,21 @@ class TestAddBoolean(test.bootstrap.IFC4): ) wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall") - builder = ShapeBuilder(self.file) - extrusion = builder.extrude(builder.rectangle()) - rep = builder.get_representation(body, extrusion) + profile = self.file.create_entity( + "IfcIShapeProfileDef", + ProfileName="HEA100", + ProfileType="AREA", + OverallWidth=100, + OverallDepth=96, + WebThickness=5, + FlangeThickness=8, + FilletRadius=12, + ) + rep = ifcopenshell.api.run( + "geometry.add_profile_representation", self.file, context=body, profile=profile, depth=5 + ) ifcopenshell.api.run("geometry.assign_representation", self.file, product=wall, representation=rep) ifcopenshell.api.run("geometry.add_boolean", self.file, representation=rep, matrix=np.eye(4)) - assert rep.Items[0].is_a() == "IfcBooleanResult" + assert rep.Items[0].is_a() == "IfcBooleanClippingResult" assert rep.RepresentationType == "CSG"