mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-01-31 09:24:07 +03:00
Added test to verify executemany doesn't propagate exceptions.
This commit is contained in:
parent
4a78e4068b
commit
bd6a4139da
|
@ -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())
|
||||
|
|
29
tests/test_cursor.py
Normal file
29
tests/test_cursor.py
Normal file
|
@ -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()
|
Loading…
Reference in New Issue
Block a user