[SQL-CVS] r4666 - SQLObject/trunk/sqlobject/tests
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: <sub...@co...> - 2013-10-05 12:24:41
|
Author: phd Date: Sat Oct 5 06:24:36 2013 New Revision: 4666 Log: Merge revision 4665 from branch 1.5: add a test for pgcode Modified: SQLObject/trunk/sqlobject/tests/test_exceptions.py Modified: SQLObject/trunk/sqlobject/tests/test_exceptions.py ============================================================================== --- SQLObject/trunk/sqlobject/tests/test_exceptions.py Sat Oct 5 06:23:22 2013 (r4665) +++ SQLObject/trunk/sqlobject/tests/test_exceptions.py Sat Oct 5 06:24:36 2013 (r4666) @@ -1,5 +1,5 @@ from sqlobject import * -from sqlobject.dberrors import DuplicateEntryError +from sqlobject.dberrors import * from sqlobject.tests.dbtest import * ######################################## @@ -9,9 +9,23 @@ class TestException(SQLObject): name = StringCol(unique=True, length=100) +class TestExceptionWithNonexistingTable(SQLObject): + pass + def test_exceptions(): if not supports("exceptions"): return setupClass(TestException) TestException(name="test") raises(DuplicateEntryError, TestException, name="test") + + connection = getConnection() + if connection.module.__name__ != 'psycopg2': + return + TestExceptionWithNonexistingTable.setConnection(connection) + try: + list(TestExceptionWithNonexistingTable.select()) + except ProgrammingError, e: + assert e.args[0].code == '42P01' + else: + assert False, "DID NOT RAISE" |