summaryrefslogtreecommitdiff
path: root/test/orm/test_bind.py
diff options
context:
space:
mode:
authorGord Thompson <gord@gordthompson.com>2021-08-12 13:04:28 -0600
committerMike Bayer <mike_mp@zzzcomputing.com>2021-09-30 10:10:16 -0400
commit257f9130c321aaa948690d0e49c7352ad1188abd (patch)
tree2648c88460c3e5de847ee998edb7a6df0aa9b261 /test/orm/test_bind.py
parentf7f2df607301afcd11dd49a2ccb632291de12d29 (diff)
downloadsqlalchemy-257f9130c321aaa948690d0e49c7352ad1188abd.tar.gz
Modernize tests - calling_mapper_directly
a few changes for py2k: * map_imperatively() includes the check that a class is being sent, this was only working for mapper() before * the test suite didn't place the py2k "autouse" workaround in the correct order, seemingly, tried to adjust the per-test ordering setup in pytestplugin.py Change-Id: I4cc39630724e810953cfda7b2afdadc8b948e3c2
Diffstat (limited to 'test/orm/test_bind.py')
-rw-r--r--test/orm/test_bind.py45
1 files changed, 27 insertions, 18 deletions
diff --git a/test/orm/test_bind.py b/test/orm/test_bind.py
index f584f22ae..3df5a2717 100644
--- a/test/orm/test_bind.py
+++ b/test/orm/test_bind.py
@@ -12,7 +12,6 @@ from sqlalchemy import true
from sqlalchemy import update
from sqlalchemy.orm import aliased
from sqlalchemy.orm import backref
-from sqlalchemy.orm import mapper
from sqlalchemy.orm import relationship
from sqlalchemy.orm import Session
from sqlalchemy.orm import sessionmaker
@@ -46,8 +45,8 @@ class BindIntegrationTest(_fixtures.FixtureTest):
users_unbound = users.to_metadata(m2)
addresses_unbound = addresses.to_metadata(m2)
- mapper(Address, addresses_unbound)
- mapper(
+ self.mapper_registry.map_imperatively(Address, addresses_unbound)
+ self.mapper_registry.map_imperatively(
User,
users_unbound,
properties={
@@ -103,8 +102,8 @@ class BindIntegrationTest(_fixtures.FixtureTest):
users_unbound = users.to_metadata(m2)
addresses_unbound = addresses.to_metadata(m2)
- mapper(Address, addresses_unbound)
- mapper(
+ self.mapper_registry.map_imperatively(Address, addresses_unbound)
+ self.mapper_registry.map_imperatively(
User,
users_unbound,
properties={
@@ -155,7 +154,7 @@ class BindIntegrationTest(_fixtures.FixtureTest):
def test_bind_from_metadata(self):
users, User = self.tables.users, self.classes.User
- mapper(User, users)
+ self.mapper_registry.map_imperatively(User, users)
session = fixture_session()
@@ -261,8 +260,10 @@ class BindIntegrationTest(_fixtures.FixtureTest):
self.classes.User,
)
- mapper(User, users, properties={"addresses": relationship(Address)})
- mapper(Address, addresses)
+ self.mapper_registry.map_imperatively(
+ User, users, properties={"addresses": relationship(Address)}
+ )
+ self.mapper_registry.map_imperatively(Address, addresses)
e1 = engines.testing_engine()
e2 = engines.testing_engine()
@@ -333,8 +334,10 @@ class BindIntegrationTest(_fixtures.FixtureTest):
self.classes.User,
)
- mapper(User, users, properties={"addresses": relationship(Address)})
- mapper(Address, addresses)
+ self.mapper_registry.map_imperatively(
+ User, users, properties={"addresses": relationship(Address)}
+ )
+ self.mapper_registry.map_imperatively(Address, addresses)
e1 = engines.testing_engine()
e2 = engines.testing_engine()
@@ -397,7 +400,9 @@ class BindIntegrationTest(_fixtures.FixtureTest):
testing.db,
)
- mapper(self.classes.User, self.tables.users)
+ self.mapper_registry.map_imperatively(
+ self.classes.User, self.tables.users
+ )
u_object = self.classes.User()
assert_raises_message(
@@ -412,7 +417,7 @@ class BindIntegrationTest(_fixtures.FixtureTest):
def test_bound_connection(self):
users, User = self.tables.users, self.classes.User
- mapper(User, users)
+ self.mapper_registry.map_imperatively(User, users)
c = testing.db.connect()
sess = Session(bind=c)
sess.begin()
@@ -440,7 +445,7 @@ class BindIntegrationTest(_fixtures.FixtureTest):
def test_bound_connection_transactional(self):
User, users = self.classes.User, self.tables.users
- mapper(User, users)
+ self.mapper_registry.map_imperatively(User, users)
with testing.db.connect() as c:
sess = Session(bind=c, autocommit=False)
@@ -508,7 +513,7 @@ class SessionBindTest(fixtures.MappedTest):
test_table.to_metadata(meta)
assert meta.tables["test_table"].bind is None
- mapper(Foo, meta.tables["test_table"])
+ cls.mapper_registry.map_imperatively(Foo, meta.tables["test_table"])
def test_session_bind(self):
Foo = self.classes.Foo
@@ -580,14 +585,18 @@ class GetBindTest(fixtures.MappedTest):
@classmethod
def setup_mappers(cls):
- mapper(cls.classes.ClassWMixin, cls.tables.w_mixin_table)
- mapper(cls.classes.BaseClass, cls.tables.base_table)
- mapper(
+ cls.mapper_registry.map_imperatively(
+ cls.classes.ClassWMixin, cls.tables.w_mixin_table
+ )
+ cls.mapper_registry.map_imperatively(
+ cls.classes.BaseClass, cls.tables.base_table
+ )
+ cls.mapper_registry.map_imperatively(
cls.classes.JoinedSubClass,
cls.tables.joined_sub_table,
inherits=cls.classes.BaseClass,
)
- mapper(
+ cls.mapper_registry.map_imperatively(
cls.classes.ConcreteSubClass,
cls.tables.concrete_sub_table,
inherits=cls.classes.BaseClass,