summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/sqlalchemy/testing/warnings.py2
-rw-r--r--test/ext/test_horizontal_shard.py3
-rw-r--r--test/orm/declarative/test_deprecations.py16
-rw-r--r--test/orm/test_deprecations.py10
-rw-r--r--test/orm/test_manytomany.py4
-rw-r--r--test/orm/test_unitofwork.py149
6 files changed, 140 insertions, 44 deletions
diff --git a/lib/sqlalchemy/testing/warnings.py b/lib/sqlalchemy/testing/warnings.py
index 40d03f0af..64060c776 100644
--- a/lib/sqlalchemy/testing/warnings.py
+++ b/lib/sqlalchemy/testing/warnings.py
@@ -77,11 +77,9 @@ def setup_filters():
#
# ORM Session
#
- r"This Session located a target engine via bound metadata",
r"The Session.autocommit parameter is deprecated ",
r".*object is being merged into a Session along the backref "
"cascade path",
- r"Passing bind arguments to Session.execute\(\) as keyword arguments",
r"The merge_result\(\) method is superseded by the "
r"merge_frozen_result\(\)",
r"The Session.begin.subtransactions flag is deprecated",
diff --git a/test/ext/test_horizontal_shard.py b/test/ext/test_horizontal_shard.py
index 192617901..6e6265ab1 100644
--- a/test/ext/test_horizontal_shard.py
+++ b/test/ext/test_horizontal_shard.py
@@ -260,7 +260,8 @@ class ShardTest(object):
sess = self._fixture_data()
eq_(
sess.execute(
- weather_locations.select(), shard_id="asia"
+ weather_locations.select(),
+ bind_arguments=dict(shard_id="asia"),
).fetchall(),
[(1, "Asia", "Tokyo")],
)
diff --git a/test/orm/declarative/test_deprecations.py b/test/orm/declarative/test_deprecations.py
index e3015f643..7267a9aa2 100644
--- a/test/orm/declarative/test_deprecations.py
+++ b/test/orm/declarative/test_deprecations.py
@@ -21,7 +21,10 @@ class BoundMetadataDeclarativeTest(fixtures.MappedTest):
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)
@@ -33,8 +36,10 @@ class BoundMetadataDeclarativeTest(fixtures.MappedTest):
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)
@@ -46,4 +51,7 @@ class BoundMetadataDeclarativeTest(fixtures.MappedTest):
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)
diff --git a/test/orm/test_deprecations.py b/test/orm/test_deprecations.py
index c66259e47..540afbbc7 100644
--- a/test/orm/test_deprecations.py
+++ b/test/orm/test_deprecations.py
@@ -6213,13 +6213,19 @@ class GetBindTest(_GetBindTest):
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):
diff --git a/test/orm/test_manytomany.py b/test/orm/test_manytomany.py
index 32dfe3af4..1abf5551a 100644
--- a/test/orm/test_manytomany.py
+++ b/test/orm/test_manytomany.py
@@ -385,7 +385,7 @@ class M2MTest(fixtures.MappedTest):
p1.place_id
p1.transitions
- sess.execute(place_input.delete(), mapper=Place)
+ sess.execute(place_input.delete())
p1.place_id = 7
assert_raises_message(
@@ -398,7 +398,7 @@ class M2MTest(fixtures.MappedTest):
p1.place_id
p1.transitions
- sess.execute(place_input.delete(), mapper=Place)
+ sess.execute(place_input.delete())
p1.transitions.remove(t1)
assert_raises_message(
orm_exc.StaleDataError,
diff --git a/test/orm/test_unitofwork.py b/test/orm/test_unitofwork.py
index d95565cd4..01cb9dcc4 100644
--- a/test/orm/test_unitofwork.py
+++ b/test/orm/test_unitofwork.py
@@ -2022,7 +2022,7 @@ class SaveTest(_fixtures.FixtureTest):
session.commit()
eq_(
- list(session.execute(orders.select(), mapper=Order)),
+ list(session.execute(orders.select())),
[(42, None, None, "foo", None)],
)
session.expunge_all()
@@ -2037,7 +2037,11 @@ class SaveTest(_fixtures.FixtureTest):
session.flush()
eq_(
- list(session.execute(orders.select(), mapper=Order)),
+ list(
+ session.execute(
+ orders.select(),
+ )
+ ),
[(42, None, None, "hoho", None)],
)
@@ -2048,7 +2052,11 @@ class SaveTest(_fixtures.FixtureTest):
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()
@@ -2216,7 +2224,7 @@ class SaveTest(_fixtures.FixtureTest):
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()
@@ -2744,7 +2752,7 @@ class ManyToManyTest(_fixtures.FixtureTest):
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"""
@@ -3141,9 +3149,20 @@ class RowSwitchTest(fixtures.MappedTest):
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)],
)
@@ -3156,9 +3175,20 @@ class RowSwitchTest(fixtures.MappedTest):
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)],
)
@@ -3189,14 +3219,33 @@ class RowSwitchTest(fixtures.MappedTest):
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",
@@ -3212,13 +3261,25 @@ class RowSwitchTest(fixtures.MappedTest):
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 = (
@@ -3241,10 +3302,22 @@ class RowSwitchTest(fixtures.MappedTest):
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)
@@ -3252,12 +3325,22 @@ class RowSwitchTest(fixtures.MappedTest):
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):