File tree Expand file tree Collapse file tree 3 files changed +13
-8
lines changed Expand file tree Collapse file tree 3 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -80,14 +80,7 @@ def setUp(self):
80
80
@reset_test_database
81
81
def tearDown (self ):
82
82
super (DecoratedClass , self ).tearDown ()
83
- if self .conn_handler ._user_conn is not None :
84
- self .conn_handler ._user_conn .close ()
85
-
86
- if self .conn_handler ._admin_conn is not None :
87
- self .conn_handler ._admin_conn .close ()
88
-
89
- if self .conn_handler ._admin_nodb_conn is not None :
90
- self .conn_handler ._admin_nodb_conn .close ()
83
+ self .conn_handler .close ()
91
84
92
85
return DecoratedClass
93
86
return class_modifier
Original file line number Diff line number Diff line change @@ -265,6 +265,7 @@ def drop_environment(ask_for_confirmation):
265
265
do_drop = True
266
266
267
267
if do_drop :
268
+ SQLConnectionHandler .close ()
268
269
admin_conn = SQLConnectionHandler (admin = 'admin_without_database' )
269
270
admin_conn .set_autocommit ('on' )
270
271
admin_conn .execute ('DROP DATABASE %s' % qiita_config .database )
Original file line number Diff line number Diff line change @@ -223,6 +223,17 @@ def _open_connection(self):
223
223
else :
224
224
self ._connection = getattr (SQLConnectionHandler , self ._conn_attr )
225
225
226
+ @staticmethod
227
+ def close ():
228
+ if SQLConnectionHandler ._user_conn is not None :
229
+ SQLConnectionHandler ._user_conn .close ()
230
+
231
+ if SQLConnectionHandler ._admin_conn is not None :
232
+ SQLConnectionHandler ._admin_conn .close ()
233
+
234
+ if SQLConnectionHandler ._admin_nodb_conn is not None :
235
+ SQLConnectionHandler ._admin_nodb_conn .close ()
236
+
226
237
@contextmanager
227
238
def get_postgres_cursor (self ):
228
239
""" Returns a Postgres cursor
You can’t perform that action at this time.
0 commit comments