from sqlobject import *
from sqlobject.dberrors import DuplicateEntryError
from sqlobject.tests.dbtest import *

########################################
## Table aliases and self-joins
########################################

class TestException(SQLObject):
    name = StringCol(unique=True, length=100)

def test_exceptions():
    if not supports("exceptions"):
        return
    setupClass(TestException)
    TestException(name="test")
    raises(DuplicateEntryError, TestException, name="test")

from sqlobject import *
from sqlobject.dberrors import *
from sqlobject.tests.dbtest import *

########################################
## Table aliases and self-joins
########################################

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"

Add a test for pgcode
Add a test for pgcode


git-svn-id: ace7fa9e7412674399eb986d17112e1377537c44@4665 95a46c32-92d2-0310-94a5-8d71aeb3d4b3
