@@ -35,9 +35,41 @@ def client() -> Client:
3535 return Client (project = project_id )
3636
3737
38+ @pytest .fixture (scope = "class" )
39+ def cleanupGSQL (client ):
40+ yield
41+
42+ print ("\n Performing GSQL cleanup after each test..." )
43+
44+ database = client .instance (instance_id ).database (google_database )
45+ operation = database .update_ddl (
46+ [
47+ f"DROP TABLE IF EXISTS { table_name } " ,
48+ ]
49+ )
50+ operation .result (OPERATION_TIMEOUT_SECONDS )
51+
52+ # Code to perform teardown after each test goes here
53+ print ("\n GSQL Cleanup complete." )
54+
55+
56+ @pytest .fixture (scope = "class" )
57+ def cleanupPGSQL (client ):
58+ yield
59+
60+ print ("\n Performing PGSQL cleanup after each test..." )
61+
62+ database = client .instance (instance_id ).database (pg_database )
63+ operation = database .update_ddl ([f"DROP TABLE IF EXISTS { table_name } " ])
64+ operation .result (OPERATION_TIMEOUT_SECONDS )
65+
66+ # Code to perform teardown after each test goes here
67+ print ("\n PGSQL Cleanup complete." )
68+
69+
3870class TestSpannerDocumentLoaderGoogleSQL :
3971 @pytest .fixture (autouse = True , scope = "class" )
40- def setup_database (self , client ):
72+ def setup_database (self , client , cleanupGSQL ):
4173 database = client .instance (instance_id ).database (google_database )
4274 operation = database .update_ddl ([f"DROP TABLE IF EXISTS { table_name } " ])
4375 operation .result (OPERATION_TIMEOUT_SECONDS )
@@ -455,7 +487,7 @@ def test_loader_custom_json_metadata(self, client):
455487
456488class TestSpannerDocumentLoaderPostgreSQL :
457489 @pytest .fixture (autouse = True , scope = "class" )
458- def setup_database (self , client ):
490+ def setup_database (self , client , cleanupPGSQL ):
459491 database = client .instance (instance_id ).database (pg_database )
460492 operation = database .update_ddl ([f"DROP TABLE IF EXISTS { table_name } " ])
461493 operation .result (OPERATION_TIMEOUT_SECONDS )
@@ -872,15 +904,15 @@ def test_loader_custom_json_metadata(self, client):
872904
873905class TestSpannerDocumentSaver :
874906 @pytest .fixture (name = "google_client" )
875- def setup_google_client (self , client ) -> Client :
907+ def setup_google_client (self , client , cleanupGSQL ) -> Client :
876908 database = client .instance (instance_id ).database (google_database )
877909 operation = database .update_ddl ([f"DROP TABLE IF EXISTS { table_name } " ])
878910 print ("table dropped" )
879911 operation .result (OPERATION_TIMEOUT_SECONDS )
880912 yield client
881913
882914 @pytest .fixture (name = "pg_client" )
883- def setup_pg_client (self , client ) -> Client :
915+ def setup_pg_client (self , client , cleanupPGSQL ) -> Client :
884916 database = client .instance (instance_id ).database (pg_database )
885917 operation = database .update_ddl ([f"DROP TABLE IF EXISTS { table_name } " ])
886918 operation .result (OPERATION_TIMEOUT_SECONDS )
0 commit comments