def test_exception_on_hello_packet(self): client = Client(self.host, self.port, self.database, 'wrong_user') with self.assertRaises(errors.ServerException) as e: client.execute('SHOW TABLES') client.disconnect() # Simple exception formatting checks exc = e.exception self.assertIn('Code:', str(exc)) self.assertIn('Stack trace:', str(exc))
def test_network_error(self): client = Client('bad-address') with self.assertRaises(errors.NetworkError): client.execute('SHOW TABLES')