mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 23:02:39 +00:00
Fix ability to run tests and segfaulting test
This commit is contained in:
@@ -350,7 +350,8 @@ def wrap_usecases(path, name):
|
|||||||
module_name = name.split(".")[-1]
|
module_name = name.split(".")[-1]
|
||||||
module = sys.modules[name]
|
module = sys.modules[name]
|
||||||
for loader, usecase_name, is_pkg in pkgutil.iter_modules(path):
|
for loader, usecase_name, is_pkg in pkgutil.iter_modules(path):
|
||||||
usecase = getattr(module, usecase_name)
|
# We may not be able to get the usecase if we are missing a dependency.
|
||||||
|
usecase = getattr(module, usecase_name, None)
|
||||||
if callable(usecase):
|
if callable(usecase):
|
||||||
usecase_path = f"{module_name}.{usecase_name}"
|
usecase_path = f"{module_name}.{usecase_name}"
|
||||||
setattr(module, usecase_name, wrap_usecase(usecase_path, usecase))
|
setattr(module, usecase_name, wrap_usecase(usecase_path, usecase))
|
||||||
|
|||||||
@@ -56,11 +56,8 @@ def add_information(
|
|||||||
attributes={"Identification": "A-GA-6100", "Name": "Overall Plan",
|
attributes={"Identification": "A-GA-6100", "Name": "Overall Plan",
|
||||||
"Location": "A-GA-6100 - Overall Plan.pdf"})
|
"Location": "A-GA-6100 - Overall Plan.pdf"})
|
||||||
"""
|
"""
|
||||||
settings = {"parent": parent}
|
|
||||||
|
|
||||||
id_attribute = "DocumentId" if file.schema == "IFC2X3" else "Identification"
|
id_attribute = "DocumentId" if file.schema == "IFC2X3" else "Identification"
|
||||||
information = file.create_entity("IfcDocumentInformation", **{id_attribute: "X", "Name": "Unnamed"})
|
information = file.create_entity("IfcDocumentInformation", **{id_attribute: "X", "Name": "Unnamed"})
|
||||||
parent = settings["parent"]
|
|
||||||
if not parent and file.by_type("IfcProject"):
|
if not parent and file.by_type("IfcProject"):
|
||||||
parent = file.by_type("IfcProject")[0]
|
parent = file.by_type("IfcProject")[0]
|
||||||
if parent.is_a("IfcProject") or parent.is_a("IfcContext"):
|
if parent.is_a("IfcProject") or parent.is_a("IfcContext"):
|
||||||
|
|||||||
@@ -22,14 +22,14 @@ import ifcopenshell.api
|
|||||||
|
|
||||||
class TestRemoveInformation(test.bootstrap.IFC4):
|
class TestRemoveInformation(test.bootstrap.IFC4):
|
||||||
def test_remove_information(self):
|
def test_remove_information(self):
|
||||||
project = self.file.createIfcProject()
|
self.file.createIfcProject()
|
||||||
element = ifcopenshell.api.run("document.add_information", self.file, parent=None)
|
element = ifcopenshell.api.run("document.add_information", self.file, parent=None)
|
||||||
ifcopenshell.api.run("document.remove_information", self.file, information=element)
|
ifcopenshell.api.run("document.remove_information", self.file, information=element)
|
||||||
assert len(self.file.by_type("IfcDocumentInformation")) == 0
|
assert len(self.file.by_type("IfcDocumentInformation")) == 0
|
||||||
assert len(self.file.by_type("IfcRelAssociatesDocument")) == 0
|
assert len(self.file.by_type("IfcRelAssociatesDocument")) == 0
|
||||||
|
|
||||||
def test_removing_all_references_of_an_information(self):
|
def test_removing_all_references_of_an_information(self):
|
||||||
project = self.file.createIfcProject()
|
self.file.createIfcProject()
|
||||||
information = ifcopenshell.api.run("document.add_information", self.file, parent=None)
|
information = ifcopenshell.api.run("document.add_information", self.file, parent=None)
|
||||||
ifcopenshell.api.run("document.add_reference", self.file, information=information)
|
ifcopenshell.api.run("document.add_reference", self.file, information=information)
|
||||||
ifcopenshell.api.run("document.remove_information", self.file, information=information)
|
ifcopenshell.api.run("document.remove_information", self.file, information=information)
|
||||||
@@ -51,7 +51,7 @@ class TestRemoveInformation(test.bootstrap.IFC4):
|
|||||||
assert len(self.file.by_type("IfcDocumentInformationRelationship")) == 0
|
assert len(self.file.by_type("IfcDocumentInformationRelationship")) == 0
|
||||||
|
|
||||||
def test_removing_all_subdocuments_and_their_references_too(self):
|
def test_removing_all_subdocuments_and_their_references_too(self):
|
||||||
project = self.file.createIfcProject()
|
self.file.createIfcProject()
|
||||||
information = ifcopenshell.api.run("document.add_information", self.file, parent=None)
|
information = ifcopenshell.api.run("document.add_information", self.file, parent=None)
|
||||||
information2 = ifcopenshell.api.run("document.add_information", self.file, parent=information)
|
information2 = ifcopenshell.api.run("document.add_information", self.file, parent=information)
|
||||||
ifcopenshell.api.run("document.add_reference", self.file, information=information2)
|
ifcopenshell.api.run("document.add_reference", self.file, information=information2)
|
||||||
@@ -62,5 +62,5 @@ class TestRemoveInformation(test.bootstrap.IFC4):
|
|||||||
assert len(self.file.by_type("IfcDocumentInformationRelationship")) == 0
|
assert len(self.file.by_type("IfcDocumentInformationRelationship")) == 0
|
||||||
|
|
||||||
|
|
||||||
class TestRemoveInformationIFC2X3(test.bootstrap.IFC2X3, TestRemoveInformation):
|
class TestRemoveInformationIFC2X3(TestRemoveInformation, test.bootstrap.IFC2X3):
|
||||||
pass
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user