mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 21:42:19 +00:00
fix bug in ifc2x3 tests bootstrap
it was creating new applications and users every time `ifcopenshell.api.owner.settings.get_user` or `ifcopenshell.api.owner.settings.get_application` was called
This commit is contained in:
@@ -20,6 +20,7 @@ import pytest
|
|||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import ifcopenshell.api
|
import ifcopenshell.api
|
||||||
import ifcopenshell.api.owner.settings
|
import ifcopenshell.api.owner.settings
|
||||||
|
import functools
|
||||||
|
|
||||||
|
|
||||||
class IFC4X3:
|
class IFC4X3:
|
||||||
@@ -46,7 +47,14 @@ class IFC2X3:
|
|||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def setup(self):
|
def setup(self):
|
||||||
self.file: ifcopenshell.file = ifcopenshell.api.run("project.create_file", version="IFC2X3")
|
self.file: ifcopenshell.file = ifcopenshell.api.run("project.create_file", version="IFC2X3")
|
||||||
ifcopenshell.api.owner.settings.get_user = lambda ifc: ifc.createIfcPersonAndOrganization()
|
|
||||||
ifcopenshell.api.owner.settings.get_application = lambda ifc: ifc.createIfcApplication()
|
@functools.cache
|
||||||
|
def get_user(ifc: ifcopenshell.file):
|
||||||
|
person = ifc.create_entity("IfcPerson")
|
||||||
|
organization = ifc.create_entity("IfcOrganization")
|
||||||
|
return ifc.create_entity("IfcPersonAndOrganization", ThePerson=person, TheOrganization=organization)
|
||||||
|
|
||||||
|
ifcopenshell.api.owner.settings.get_user = get_user
|
||||||
|
ifcopenshell.api.owner.settings.get_application = functools.cache(lambda ifc: ifc.createIfcApplication())
|
||||||
ifcopenshell.api.pre_listeners = {}
|
ifcopenshell.api.pre_listeners = {}
|
||||||
ifcopenshell.api.post_listeners = {}
|
ifcopenshell.api.post_listeners = {}
|
||||||
|
|||||||
Reference in New Issue
Block a user