@@ -49,9 +49,10 @@ def store(db_backend):
4949 True ,
5050 )
5151
52- yield store
53-
54- store .metadata .drop_all (db_backend .database_connection )
52+ try :
53+ yield store
54+ finally :
55+ store .metadata .drop_all (db_backend .database_connection )
5556
5657
5758# Artifacts
@@ -905,11 +906,8 @@ class TestClass:
905906 _unregister (reg_section , TestClass ._type , ext_id )
906907
907908
908- def test_property (db_backend , object_variation ):
909- """
910- Try to more exhaustively test many different property configurations:
911- ensure schemas can be created and values can be stored and retrieved.
912- """
909+ @pytest .fixture
910+ def property_store (db_backend , object_variation ):
913911 rdb_store = RelationalDBStore (
914912 db_backend ,
915913 True ,
@@ -919,12 +917,22 @@ def test_property(db_backend, object_variation):
919917 type (object_variation ),
920918 )
921919
922- rdb_store .add (object_variation )
923- read_obj = rdb_store .get (object_variation ["id" ])
920+ try :
921+ yield rdb_store
922+ finally :
923+ rdb_store .metadata .drop_all (db_backend .database_connection )
924924
925- assert read_obj == object_variation
926925
927- rdb_store .metadata .drop_all (db_backend .database_connection )
926+ def test_property (property_store , object_variation ):
927+ """
928+ Try to more exhaustively test many different property configurations:
929+ ensure schemas can be created and values can be stored and retrieved.
930+ """
931+
932+ property_store .add (object_variation )
933+ read_obj = property_store .get (object_variation ["id" ])
934+
935+ assert read_obj == object_variation
928936
929937
930938def test_dictionary_property_complex (db_backend ):
@@ -961,11 +969,12 @@ def test_dictionary_property_complex(db_backend):
961969 cls ,
962970 )
963971
964- rdb_store .add (obj )
965- read_obj = rdb_store .get (obj ["id" ])
966- assert read_obj == obj
967-
968- rdb_store .metadata .drop_all (db_backend .database_connection )
972+ try :
973+ rdb_store .add (obj )
974+ read_obj = rdb_store .get (obj ["id" ])
975+ assert read_obj == obj
976+ finally :
977+ rdb_store .metadata .drop_all (db_backend .database_connection )
969978
970979
971980def test_extension_definition (store ):
0 commit comments