def test_error_in_callback(self): # behaviour changed after issue #113: if there is an error in the # callback for the moment we don't have a way to reset the connection # without blocking (ticket #113) so just close it. conn = self.conn curs = conn.cursor() curs.execute("select 1") # have a BEGIN curs.fetchone() # now try to do something that will fail in the callback extensions.set_wait_callback(lambda conn: 1 // 0) self.assertRaises(ZeroDivisionError, curs.execute, "select 2") self.assert_(conn.closed)
def test_error_in_callback(self): # behaviour changed after issue #113: if there is an error in the # callback for the moment we don't have a way to reset the connection # without blocking (ticket #113) so just close it. conn = self.conn curs = conn.cursor() curs.execute("select 1") # have a BEGIN curs.fetchone() # now try to do something that will fail in the callback extensions.set_wait_callback(lambda conn: 1//0) self.assertRaises(ZeroDivisionError, curs.execute, "select 2") self.assert_(conn.closed)
def set_stub_wait_callback(self, conn): stub = ConnectionStub(conn) extensions.set_wait_callback(lambda conn: extras.wait_select(stub)) return stub
def tearDown(self): ConnectingTestCase.tearDown(self) extensions.set_wait_callback(self._cb)
def setUp(self): self._cb = extensions.get_wait_callback() extensions.set_wait_callback(extras.wait_select) ConnectingTestCase.setUp(self)