# Path: axiom/errors.py
# class TimeoutError(Exception):
#     """
#     A low-level SQL operation timed out.
# 
#     @ivar statement: The SQL statement which timed out.
#     @ivar timeout: The timeout, in seconds, which was exceeded.
#     @ivar underlying: The backend exception which signaled this, or None.
#     """
#     def __init__(self, statement, timeout, underlying):
#         Exception.__init__(self, statement, timeout, underlying)
#         self.statement = statement
#         self.timeout = timeout
#         self.underlying = underlying
# 
# class TableAlreadyExists(SQLError):
#     """
#     Axiom internally created a table at the same time as another database.
#     (User code should not need to catch this exception.)
#     """
# 
# class SQLError(RuntimeError):
#     """
#     Axiom internally generated some bad SQL.
#     """
#     def __init__(self, sql, args, underlying):
#         RuntimeError.__init__(self, sql, args, underlying)
#         self.sql, self.args, self.underlying = self.args
# 
#     def __str__(self):
#         return "<SQLError: {!r}({!r}) caused {}: {}>".format(
#             self.sql, self.args,
#             self.underlying.__class__, self.underlying)


from axiom.errors import TimeoutError, TableAlreadyExists, SQLError
    def createStubConnection(self):
        raise NotImplementedError("Cannot create Axiom Connection instance.")


    def createRealConnection(self):
        """
        Create a memory-backed database connection for integration testing.
        """
        raise NotImplementedError("Real connection creation not implemented.")


    def test_identifyTableCreationError(self):
        """
        When the same table is created twice, we should get a TableAlreadyExists
        exception.
        """
        con = self.createRealConnection()
        cur = con.cursor()
        CREATE_TABLE = "create table foo (bar integer)"
        cur.execute(CREATE_TABLE)
        e = self.assertRaises(TableAlreadyExists, cur.execute, CREATE_TABLE)


    def test_identifyGenericError(self):
        """
        When invalid SQL is issued, we should get a SQLError exception.
        """
        con = self.createRealConnection()
        cur = con.cursor()
        INVALID_STATEMENT = "not an SQL string"

# Path: axiom/errors.py
# class TimeoutError(Exception):
#     """
#     A low-level SQL operation timed out.
# 
#     @ivar statement: The SQL statement which timed out.
#     @ivar timeout: The timeout, in seconds, which was exceeded.
#     @ivar underlying: The backend exception which signaled this, or None.
#     """
#     def __init__(self, statement, timeout, underlying):
#         Exception.__init__(self, statement, timeout, underlying)
#         self.statement = statement
#         self.timeout = timeout
#         self.underlying = underlying
# 
# class TableAlreadyExists(SQLError):
#     """
#     Axiom internally created a table at the same time as another database.
#     (User code should not need to catch this exception.)
#     """
# 
# class SQLError(RuntimeError):
#     """
#     Axiom internally generated some bad SQL.
#     """
#     def __init__(self, sql, args, underlying):
#         RuntimeError.__init__(self, sql, args, underlying)
#         self.sql, self.args, self.underlying = self.args
# 
#     def __str__(self):
#         return "<SQLError: {!r}({!r}) caused {}: {}>".format(
#             self.sql, self.args,
#             self.underlying.__class__, self.underlying)


# Path: axiom/test/cursortest.py
from axiom.errors import TimeoutError, TableAlreadyExists, SQLError

    def createStubConnection(self):
        raise NotImplementedError("Cannot create Axiom Connection instance.")


    def createRealConnection(self):
        """
        Create a memory-backed database connection for integration testing.
        """
        raise NotImplementedError("Real connection creation not implemented.")


    def test_identifyTableCreationError(self):
        """
        When the same table is created twice, we should get a TableAlreadyExists
        exception.
        """
        con = self.createRealConnection()
        cur = con.cursor()
        CREATE_TABLE = "create table foo (bar integer)"
        cur.execute(CREATE_TABLE)
        e = self.assertRaises(TableAlreadyExists, cur.execute, CREATE_TABLE)


    def test_identifyGenericError(self):
        """
        When invalid SQL is issued, we should get a SQLError exception.
        """
        con = self.createRealConnection()
        cur = con.cursor()
        INVALID_STATEMENT = "not an SQL string"

        e = self.assertRaises(SQLError, cur.execute, INVALID_STATEMENT)