s = Session()
- is_(s.get_bind(User), testing.db)
+ with testing.expect_deprecated_20(
+ "This Session located a target engine via bound metadata"
+ ):
+ is_(s.get_bind(User), testing.db)
def test_bound_cls_registry_base(self):
reg = registry(_bind=testing.db)
id = Column(Integer, primary_key=True)
s = Session()
-
- is_(s.get_bind(User), testing.db)
+ with testing.expect_deprecated_20(
+ "This Session located a target engine via bound metadata"
+ ):
+ is_(s.get_bind(User), testing.db)
def test_bound_cls_registry_decorated(self):
reg = registry(_bind=testing.db)
s = Session()
- is_(s.get_bind(User), testing.db)
+ with testing.expect_deprecated_20(
+ "This Session located a target engine via bound metadata"
+ ):
+ is_(s.get_bind(User), testing.db)
def test_fallback_table_metadata(self):
session = self._fixture({})
- is_(session.get_bind(self.classes.BaseClass), testing.db)
+ with testing.expect_deprecated_20(
+ "This Session located a target engine via bound metadata"
+ ):
+ is_(session.get_bind(self.classes.BaseClass), testing.db)
def test_bind_base_table_concrete_sub_class(self):
base_class_bind = Mock()
session = self._fixture({self.tables.base_table: base_class_bind})
- is_(session.get_bind(self.classes.ConcreteSubClass), testing.db)
+ with testing.expect_deprecated_20(
+ "This Session located a target engine via bound metadata"
+ ):
+ is_(session.get_bind(self.classes.ConcreteSubClass), testing.db)
class DeprecationScopedSessionTest(fixtures.MappedTest):
session.commit()
eq_(
- list(session.execute(orders.select(), mapper=Order)),
+ list(session.execute(orders.select())),
[(42, None, None, "foo", None)],
)
session.expunge_all()
session.flush()
eq_(
- list(session.execute(orders.select(), mapper=Order)),
+ list(
+ session.execute(
+ orders.select(),
+ )
+ ),
[(42, None, None, "hoho", None)],
)
o.description = None
session.flush()
eq_(
- list(session.execute(orders.select(), mapper=Order)),
+ list(
+ session.execute(
+ orders.select(),
+ )
+ ),
[(42, None, None, None, None)],
)
session.close()
session.flush()
# test insert ordering is maintained
- assert names == ["user1", "user2", "user4", "user5", "user3"]
+ eq_(names, ["user1", "user2", "user4", "user5", "user3"])
session.expunge_all()
sa.orm.clear_mappers()
session.expunge_all()
item = session.query(Item).get(item.id)
- assert item.keywords == [k1, k2]
+ eq_(item.keywords, [k1, k2])
def test_association(self):
"""Basic test of an association object"""
sess.add(o5)
sess.flush()
- eq_(list(sess.execute(t5.select(), mapper=T5)), [(1, "some t5")])
eq_(
- list(sess.execute(t6.select().order_by(t6.c.id), mapper=T5)),
+ list(
+ sess.execute(
+ t5.select(),
+ )
+ ),
+ [(1, "some t5")],
+ )
+ eq_(
+ list(
+ sess.execute(
+ t6.select().order_by(t6.c.id),
+ )
+ ),
[(1, "some t6", 1), (2, "some other t6", 1)],
)
sess.add(o6)
sess.flush()
- eq_(list(sess.execute(t5.select(), mapper=T5)), [(1, "some other t5")])
eq_(
- list(sess.execute(t6.select().order_by(t6.c.id), mapper=T5)),
+ list(
+ sess.execute(
+ t5.select(),
+ )
+ ),
+ [(1, "some other t5")],
+ )
+ eq_(
+ list(
+ sess.execute(
+ t6.select().order_by(t6.c.id),
+ )
+ ),
[(3, "third t6", 1), (4, "fourth t6", 1)],
)
sess.add(o5)
sess.flush()
- assert list(sess.execute(t5.select(), mapper=T5)) == [(1, "some t5")]
- assert testing.rowset(sess.execute(t5t7.select(), mapper=T5)) == set(
- [(1, 1), (1, 2)]
+ eq_(
+ list(
+ sess.execute(
+ t5.select(),
+ )
+ ),
+ [(1, "some t5")],
+ )
+ eq_(
+ testing.rowset(
+ sess.execute(
+ t5t7.select(),
+ )
+ ),
+ set([(1, 1), (1, 2)]),
+ )
+ eq_(
+ list(
+ sess.execute(
+ t7.select(),
+ )
+ ),
+ [
+ (1, "some t7"),
+ (2, "some other t7"),
+ ],
)
- assert list(sess.execute(t7.select(), mapper=T5)) == [
- (1, "some t7"),
- (2, "some other t7"),
- ]
o6 = T5(
data="some other t5",
sess.add(o6)
sess.flush()
- assert list(sess.execute(t5.select(), mapper=T5)) == [
- (1, "some other t5")
- ]
- assert list(sess.execute(t7.select(), mapper=T5)) == [
- (3, "third t7"),
- (4, "fourth t7"),
- ]
+ eq_(
+ list(
+ sess.execute(
+ t5.select(),
+ )
+ ),
+ [(1, "some other t5")],
+ )
+ eq_(
+ list(
+ sess.execute(
+ t7.select(),
+ )
+ ),
+ [
+ (3, "third t7"),
+ (4, "fourth t7"),
+ ],
+ )
def test_manytoone(self):
t6, T6, t5, T5 = (
sess.add(o5)
sess.flush()
- assert list(sess.execute(t5.select(), mapper=T5)) == [(1, "some t5")]
- assert list(sess.execute(t6.select(), mapper=T5)) == [
- (1, "some t6", 1)
- ]
+ eq_(
+ list(
+ sess.execute(
+ t5.select(),
+ )
+ ),
+ [(1, "some t5")],
+ )
+ eq_(
+ list(
+ sess.execute(
+ t6.select(),
+ )
+ ),
+ [(1, "some t6", 1)],
+ )
o6 = T6(data="some other t6", id=1, t5=T5(data="some other t5", id=2))
sess.delete(o5)
sess.add(o6)
sess.flush()
- assert list(sess.execute(t5.select(), mapper=T5)) == [
- (2, "some other t5")
- ]
- assert list(sess.execute(t6.select(), mapper=T5)) == [
- (1, "some other t6", 2)
- ]
+ eq_(
+ list(
+ sess.execute(
+ t5.select(),
+ )
+ ),
+ [(2, "some other t5")],
+ )
+ eq_(
+ list(
+ sess.execute(
+ t6.select(),
+ )
+ ),
+ [(1, "some other t6", 2)],
+ )
class InheritingRowSwitchTest(fixtures.MappedTest):