summaryrefslogtreecommitdiff
path: root/tests/test_module.py
diff options
context:
space:
mode:
authorMatthew Woodcraft <matthew@woodcraft.me.uk>2013-03-17 16:41:15 +0000
committerMatthew Woodcraft <matthew@woodcraft.me.uk>2013-03-17 16:41:15 +0000
commitc75a3bbab4a257745fc2342c1be2b643f4a59e8f (patch)
treeb4eb632b07702cac6d8c5ca11eeba7d44cdc1e94 /tests/test_module.py
parente8db9954d16e412903cbf412f6636939ad6c437d (diff)
downloadpsycopg2-c75a3bbab4a257745fc2342c1be2b643f4a59e8f.tar.gz
Work-in-progress support for retrieving PG_DIAG result error fields.
Diffstat (limited to 'tests/test_module.py')
-rwxr-xr-xtests/test_module.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/test_module.py b/tests/test_module.py
index 4083c36..f6b3631 100755
--- a/tests/test_module.py
+++ b/tests/test_module.py
@@ -22,7 +22,8 @@
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
# License for more details.
-from testutils import unittest, skip_before_python
+from testutils import unittest, skip_before_python, skip_before_postgres
+
from testconfig import dsn
import psycopg2
@@ -154,6 +155,24 @@ class ExceptionsTestCase(unittest.TestCase):
self.assert_(e.pgerror)
self.assert_(e.cursor is cur)
+ @skip_before_postgres(9, 3)
+ def test_diagnostics(self):
+ cur = self.conn.cursor()
+ cur.execute("""
+ create temp table test_exc (
+ data int constraint chk_eq1 check (data = 1)
+ )""")
+ try:
+ cur.execute("insert into test_exc values(2)")
+ except psycopg2.Error, exc:
+ e = exc
+ self.assertEqual(e.pgcode, '23514')
+ self.assertEqual(e.diag.schema_name[:7], "pg_temp")
+ self.assertEqual(e.diag.table_name, "test_exc")
+ self.assertEqual(e.diag.column_name, None)
+ self.assertEqual(e.diag.constraint_name, "chk_eq1")
+ self.assertEqual(e.diag.datatype_name, None)
+
@skip_before_python(2, 5)
def test_pickle(self):
import pickle