2024-05-13 08:28:44 +00:00
|
|
|
import bpy
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def setup_data(request):
|
|
|
|
print("\nSetting up resources...")
|
|
|
|
|
2024-05-26 16:33:06 +00:00
|
|
|
schema_path = "../../testing/bevy_example/assets/registry.json"
|
2024-05-13 08:28:44 +00:00
|
|
|
|
2024-05-26 16:33:06 +00:00
|
|
|
yield {"schema_path": schema_path}
|
2024-05-13 08:28:44 +00:00
|
|
|
|
|
|
|
def finalizer():
|
|
|
|
print("\nPerforming teardown...")
|
|
|
|
registry = bpy.context.window_manager.components_registry
|
|
|
|
|
|
|
|
type_infos = registry.type_infos
|
|
|
|
object = bpy.context.object
|
|
|
|
remove_component_operator = bpy.ops.object.remove_bevy_component
|
|
|
|
|
|
|
|
for long_name in type_infos:
|
|
|
|
definition = type_infos[long_name]
|
|
|
|
component_name = definition["short_name"]
|
|
|
|
if component_name in object:
|
|
|
|
try:
|
|
|
|
remove_component_operator(component_name=component_name)
|
|
|
|
except Exception as error:
|
|
|
|
pass
|
|
|
|
|
|
|
|
request.addfinalizer(finalizer)
|
|
|
|
|
|
|
|
return None
|