diff options
author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2010-07-09 15:23:02 +0100 |
---|---|---|
committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2010-07-09 15:23:02 +0100 |
commit | bd6a4139da68bd84635872830bfc2949773eacee (patch) | |
tree | 970de4b2bbe6d0436ef7d8a3a5917f38b1201c2b /tests | |
parent | 4a78e4068ba972f9543fdc6b8b5005cd08cc2020 (diff) | |
download | psycopg2-bd6a4139da68bd84635872830bfc2949773eacee.tar.gz |
Added test to verify executemany doesn't propagate exceptions.
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/__init__.py | 2 | ||||
-rw-r--r-- | tests/test_cursor.py | 29 |
2 files changed, 31 insertions, 0 deletions
diff --git a/tests/__init__.py b/tests/__init__.py index 2a79948..1c8f6f2 100755 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -37,6 +37,7 @@ import test_dates import test_psycopg2_dbapi20 import test_quote import test_connection +import test_cursor import test_transaction import types_basic import types_extras @@ -54,6 +55,7 @@ def test_suite(): suite.addTest(test_psycopg2_dbapi20.test_suite()) suite.addTest(test_quote.test_suite()) suite.addTest(test_connection.test_suite()) + suite.addTest(test_cursor.test_suite()) suite.addTest(test_transaction.test_suite()) suite.addTest(types_basic.test_suite()) suite.addTest(types_extras.test_suite()) diff --git a/tests/test_cursor.py b/tests/test_cursor.py new file mode 100644 index 0000000..38c368a --- /dev/null +++ b/tests/test_cursor.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +import unittest +import psycopg2 +import psycopg2.extensions +import tests + +class CursorTests(unittest.TestCase): + + def connect(self): + return psycopg2.connect(tests.dsn) + + def test_executemany_propagate_exceptions(self): + conn = self.connect() + cur = conn.cursor() + cur.execute("create temp table test_exc (data int);") + def buggygen(): + yield 1/0 + self.assertRaises(ZeroDivisionError, + cur.executemany, "insert into test_exc values (%s)", buggygen()) + cur.close() + conn.close() + + +def test_suite(): + return unittest.TestLoader().loadTestsFromName(__name__) + +if __name__ == "__main__": + unittest.main() |