summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing/suite/test_dialect.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/testing/suite/test_dialect.py')
-rw-r--r--lib/sqlalchemy/testing/suite/test_dialect.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/sqlalchemy/testing/suite/test_dialect.py b/lib/sqlalchemy/testing/suite/test_dialect.py
new file mode 100644
index 000000000..5ad5694b3
--- /dev/null
+++ b/lib/sqlalchemy/testing/suite/test_dialect.py
@@ -0,0 +1,39 @@
+from .. import fixtures, config
+from sqlalchemy import exc
+from sqlalchemy import Integer, String
+from .. import assert_raises
+from ..schema import Table, Column
+
+
+class ExceptionTest(fixtures.TablesTest):
+ """Test basic exception wrapping.
+
+ DBAPIs vary a lot in exception behavior so to actually anticipate
+ specific exceptions from real round trips, we need to be conservative.
+
+ """
+ run_deletes = 'each'
+
+ __backend__ = True
+
+ @classmethod
+ def define_tables(cls, metadata):
+ Table('manual_pk', metadata,
+ Column('id', Integer, primary_key=True, autoincrement=False),
+ Column('data', String(50))
+ )
+
+ def test_integrity_error(self):
+
+ with config.db.begin() as conn:
+ conn.execute(
+ self.tables.manual_pk.insert(),
+ {'id': 1, 'data': 'd1'}
+ )
+
+ assert_raises(
+ exc.IntegrityError,
+ conn.execute,
+ self.tables.manual_pk.insert(),
+ {'id': 1, 'data': 'd1'}
+ )