@@ -710,6 +710,7 @@ def mysql_pymysql_engine_types(mysql_pymysql_engine, types_data):
710
710
def mysql_pymysql_conn (mysql_pymysql_engine ):
711
711
with mysql_pymysql_engine .connect () as conn :
712
712
yield conn
713
+ conn .close ()
713
714
714
715
715
716
@pytest .fixture
@@ -724,6 +725,7 @@ def mysql_pymysql_conn_iris(mysql_pymysql_engine_iris):
724
725
def mysql_pymysql_conn_types (mysql_pymysql_engine_types ):
725
726
with mysql_pymysql_engine_types .connect () as conn :
726
727
yield conn
728
+ conn .close ()
727
729
728
730
729
731
@pytest .fixture
@@ -765,6 +767,7 @@ def postgresql_psycopg2_engine_types(postgresql_psycopg2_engine, types_data):
765
767
def postgresql_psycopg2_conn (postgresql_psycopg2_engine ):
766
768
with postgresql_psycopg2_engine .connect () as conn :
767
769
yield conn
770
+ conn .close ()
768
771
769
772
770
773
@pytest .fixture
@@ -776,6 +779,7 @@ def postgresql_adbc_conn():
776
779
uri = "postgresql://postgres:postgres@localhost:5432/pandas"
777
780
with dbapi .connect (uri ) as conn :
778
781
yield conn
782
+ conn .close ()
779
783
780
784
781
785
@pytest .fixture
@@ -793,7 +797,6 @@ def postgresql_adbc_iris(request, postgresql_adbc_conn, iris_path):
793
797
create_and_load_iris_view (conn , iris_table_uuid , iris_view_uuid )
794
798
795
799
yield conn , iris_table_uuid , iris_view_uuid
796
- conn .drop ()
797
800
798
801
799
802
@pytest .fixture
@@ -814,8 +817,9 @@ def postgresql_psycopg2_conn_iris(postgresql_psycopg2_engine_iris):
814
817
815
818
@pytest .fixture
816
819
def postgresql_psycopg2_conn_types (postgresql_psycopg2_engine_types ):
817
- with postgresql_psycopg2_engine_types .connect () as conn :
818
- yield conn
820
+ conn = postgresql_psycopg2_engine_types .connect ()
821
+ yield conn
822
+ conn .close ()
819
823
820
824
821
825
@pytest .fixture
@@ -835,11 +839,11 @@ def sqlite_engine(sqlite_str):
835
839
836
840
@pytest .fixture
837
841
def sqlite_conn (sqlite_engine ):
838
- with sqlite_engine .connect () as conn :
839
- try :
840
- yield conn
841
- finally :
842
- conn .close ()
842
+ conn = sqlite_engine .connect ()
843
+ try :
844
+ yield conn
845
+ finally :
846
+ conn .close ()
843
847
844
848
845
849
@pytest .fixture
@@ -864,11 +868,11 @@ def sqlite_engine_iris(request, iris_path, sqlite_engine):
864
868
uuid_root = f"{ calling_test_name } _" + f"{ uuid .uuid4 ().hex } " [0 :10 ]
865
869
iris_table_uuid = "tbl_" + uuid_root
866
870
iris_view_uuid = "view_" + uuid_root
867
- conn = sqlite_engine
871
+ engine = sqlite_engine
868
872
869
- create_and_load_iris_sqlite3 (conn , iris_path , iris_table_uuid )
870
- create_and_load_iris_view (conn , iris_table_uuid , iris_view_uuid )
871
- yield conn , iris_table_uuid , iris_view_uuid
873
+ create_and_load_iris_sqlite3 (engine , iris_path , iris_table_uuid )
874
+ create_and_load_iris_view (engine , iris_table_uuid , iris_view_uuid )
875
+ yield engine , iris_table_uuid , iris_view_uuid
872
876
873
877
874
878
@pytest .fixture
@@ -958,12 +962,11 @@ def sqlite_buildin_iris(request, sqlite_buildin, iris_path):
958
962
uuid_root = f"{ calling_test_name } _" + f"{ uuid .uuid4 ().hex } " [0 :10 ]
959
963
iris_table_uuid = "tbl_" + uuid_root
960
964
iris_view_uuid = "view_" + uuid_root
961
- conn = sqlite3 . connect ( ":memory:" )
965
+ conn = sqlite_buildin
962
966
963
967
create_and_load_iris_sqlite3 (conn , iris_path , iris_table_uuid )
964
968
create_and_load_iris_view (conn , iris_table_uuid , iris_view_uuid )
965
969
yield conn , iris_table_uuid , iris_view_uuid
966
- # conn.close()
967
970
968
971
969
972
@pytest .fixture
@@ -1065,14 +1068,12 @@ def iris_connect_and_per_test_id(request, iris_path):
1065
1068
conn_name = request .param [0 ]
1066
1069
1067
1070
conn , table_uuid , view_uuid = request .getfixturevalue (conn_name )
1068
-
1069
1071
yield {
1070
1072
"conn" : conn ,
1071
1073
"iris_table_uuid" : table_uuid ,
1072
1074
"iris_view_uuid" : view_uuid ,
1073
1075
"conn_name" : conn_name ,
1074
1076
}
1075
- sqlalchemy = pytest .importorskip ("sqlalchemy" )
1076
1077
if isinstance (conn , str ):
1077
1078
conn = sqlalchemy .create_engine (conn )
1078
1079
drop_view (view_uuid , conn )
@@ -1081,13 +1082,6 @@ def iris_connect_and_per_test_id(request, iris_path):
1081
1082
else :
1082
1083
drop_view (view_uuid , conn )
1083
1084
drop_table (table_uuid , conn )
1084
- if isinstance (conn , sqlalchemy .Engine ):
1085
- conn .dispose ()
1086
- if isinstance (conn , sqlalchemy .Connection ):
1087
- Engine = conn .engine
1088
- conn .close ()
1089
- Engine .dispose ()
1090
-
1091
1085
1092
1086
1093
1087
connectables_to_create_uuid_function_map = {
@@ -1203,17 +1197,11 @@ def connect_and_uuid_types(request, types_data):
1203
1197
"conn_name" : conn_name ,
1204
1198
}
1205
1199
if isinstance (conn , str ):
1206
- conn = sqlalchemy .create_engine (conn )
1207
- drop_table_uuid_views (conn , table_uuid , view_uuid )
1208
- conn .dispose ()
1200
+ engine = sqlalchemy .create_engine (conn )
1201
+ drop_table_uuid_views (engine , table_uuid , view_uuid )
1202
+ engine .dispose ()
1209
1203
else :
1210
1204
drop_table_uuid_views (conn , table_uuid , view_uuid )
1211
- if isinstance (conn , sqlalchemy .Engine ):
1212
- conn .dispose ()
1213
- if isinstance (conn , sqlalchemy .Connection ):
1214
- Engine = conn .engine
1215
- conn .close ()
1216
- Engine .dispose ()
1217
1205
1218
1206
1219
1207
@pytest .fixture
@@ -1232,17 +1220,11 @@ def connect_and_uuid(request, types_data):
1232
1220
"conn_name" : conn_name ,
1233
1221
}
1234
1222
if isinstance (conn , str ):
1235
- conn = sqlalchemy .create_engine (conn )
1236
- drop_table_uuid_views (conn , table_uuid , view_uuid )
1237
- conn .dispose ()
1223
+ engine = sqlalchemy .create_engine (conn )
1224
+ drop_table_uuid_views (engine , table_uuid , view_uuid )
1225
+ engine .dispose ()
1238
1226
else :
1239
1227
drop_table_uuid_views (conn , table_uuid , view_uuid )
1240
- if isinstance (conn , sqlalchemy .Engine ):
1241
- conn .dispose ()
1242
- if isinstance (conn , sqlalchemy .Connection ):
1243
- Engine = conn .engine
1244
- conn .close ()
1245
- Engine .dispose ()
1246
1228
1247
1229
1248
1230
0 commit comments