equal
deleted
inserted
replaced
281 self.setup_database() |
281 self.setup_database() |
282 self.commit() |
282 self.commit() |
283 MAILBOX[:] = [] # reset mailbox |
283 MAILBOX[:] = [] # reset mailbox |
284 |
284 |
285 def tearDown(self): |
285 def tearDown(self): |
286 try: |
286 if not self.cnx._closed: |
287 self.cnx.rollback() |
287 self.cnx.rollback() |
288 except ProgrammingError: |
|
289 pass |
|
290 for cnx in self._cnxs: |
288 for cnx in self._cnxs: |
291 if not cnx._closed: |
289 if not cnx._closed: |
292 cnx.close() |
290 cnx.close() |
293 |
291 |
294 def setup_database(self): |
292 def setup_database(self): |
335 self.cnx.anonymous_connection = True |
333 self.cnx.anonymous_connection = True |
336 return self.cnx |
334 return self.cnx |
337 |
335 |
338 def restore_connection(self): |
336 def restore_connection(self): |
339 if not self.cnx is self._orig_cnx[0]: |
337 if not self.cnx is self._orig_cnx[0]: |
|
338 if not cnx._closed: |
|
339 self.cnx.close() |
340 try: |
340 try: |
341 self.cnx.close() |
|
342 self._cnxs.remove(self.cnx) |
341 self._cnxs.remove(self.cnx) |
343 except ProgrammingError: |
342 except ValueError: |
344 pass # already closed |
343 pass |
345 self.cnx, self.websession = self._orig_cnx |
344 self.cnx, self.websession = self._orig_cnx |
346 |
345 |
347 # db api ################################################################## |
346 # db api ################################################################## |
348 |
347 |
349 @nocoverage |
348 @nocoverage |
371 @nocoverage |
370 @nocoverage |
372 def rollback(self): |
371 def rollback(self): |
373 try: |
372 try: |
374 self.cnx.rollback() |
373 self.cnx.rollback() |
375 except ProgrammingError: |
374 except ProgrammingError: |
376 pass |
375 pass # connection closed |
377 finally: |
376 finally: |
378 self.session.set_pool() # ensure pool still set after commit |
377 self.session.set_pool() # ensure pool still set after commit |
379 |
378 |
380 # # server side db api ####################################################### |
379 # # server side db api ####################################################### |
381 |
380 |