Skip to content

Commit 799be9a

Browse files
committed
Don't use "is" to compare exceptions
psycopg2 is introducing a fine grained exception model where most exceptions will be specialized subclasses, so don't use "is" to compare an expression type Change-Id: I2eac7503e38136f0dcc0da6f77b0b1d83ea1c6dc (cherry picked from commit c5e888a)
1 parent ae9f733 commit 799be9a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

test/orm/test_transaction.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from sqlalchemy.orm.util import identity_key
66
from sqlalchemy.testing import (
77
fixtures, engines, eq_, assert_raises, assert_raises_message,
8-
assert_warnings, mock, expect_warnings, is_, is_not_)
8+
assert_warnings, mock, expect_warnings, is_, is_not_, is_true)
99
from sqlalchemy.orm import (
1010
exc as orm_exc, Session, mapper, sessionmaker, create_session,
1111
relationship, attributes, session as _session)
@@ -582,9 +582,11 @@ def prevent_savepoint_rollback(
582582
except sa_exc.DBAPIError as dbe_outer:
583583
caught_exceptions.append(dbe_outer.orig)
584584

585-
is_(
586-
type(evented_exceptions[0]),
587-
testing.db.dialect.dbapi.IntegrityError
585+
is_true(
586+
isinstance(
587+
evented_exceptions[0],
588+
testing.db.dialect.dbapi.IntegrityError
589+
)
588590
)
589591
eq_(evented_exceptions[1], rollback_error)
590592
eq_(len(evented_exceptions), 2)

0 commit comments

Comments
 (0)