summaryrefslogtreecommitdiff
path: root/tests/test_transaction.py
diff options
context:
space:
mode:
authorJames Henstridge <james@jamesh.id.au>2008-01-11 15:10:21 +0000
committerJames Henstridge <james@jamesh.id.au>2008-01-11 15:10:21 +0000
commit7d80c05748ae8ebb4cda0ecfef2919751f6170e8 (patch)
tree47c32e84114d8ec66e883f3f79516e2c71d681cb /tests/test_transaction.py
parent86597f6939bc2c3b1be94f1b46eebb76f8ccad12 (diff)
downloadpsycopg2-7d80c05748ae8ebb4cda0ecfef2919751f6170e8.tar.gz
* tests/test_transaction.py
(TransactionTestCase.test_failed_commit): Expect IntegrityError instead of OperationalError. * psycopg/pqpath.c (exception_from_sqlstate): new function that converts an SQLSTATE error code to the corresponding exception class. (pq_raise): use exception_from_sqlstate() to pick which exception to use when working with protocol version 3. (pq_complete_error): Let pq_raise() pick an appropriate exception rather than forcing OperationalError.
Diffstat (limited to 'tests/test_transaction.py')
-rwxr-xr-xtests/test_transaction.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/tests/test_transaction.py b/tests/test_transaction.py
index 285d5e4..81fe54b 100755
--- a/tests/test_transaction.py
+++ b/tests/test_transaction.py
@@ -62,7 +62,7 @@ class TransactionTestCase(unittest.TestCase):
curs.execute('INSERT INTO table2 VALUES (2, 42)')
# The commit should fail, and move the cursor back to READY state
self.assertEqual(self.conn.status, STATUS_BEGIN)
- self.assertRaises(psycopg2.OperationalError, self.conn.commit)
+ self.assertRaises(psycopg2.IntegrityError, self.conn.commit)
self.assertEqual(self.conn.status, STATUS_READY)
# The connection should be ready to use for the next transaction:
curs.execute('SELECT 1')