From 6fccdf4a285d5332ef49f23dc18c3ce45501d78b Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 4 Jan 2021 15:18:25 -0500 Subject: remove more bound metadata in Iae6ab95938a7e92b6d42086aec534af27b5577d3 I missed that the "bind" was being stuck onto the MetaData in TablesTest, which led thousands of ORM tests to still use bound metadata. Keep looking for bound metadata. standardize all ORM tests on a single means of getting a Session when the Session API isn't the thing we are directly testing, using a new function fixture_session() that replaces create_session() and uses modern defaults. Change-Id: Iaf71206e9ee568151496d8bc213a069504bf65ef --- lib/sqlalchemy/testing/fixtures.py | 7 ++++++- lib/sqlalchemy/testing/suite/test_rowcount.py | 11 +++++++---- lib/sqlalchemy/testing/warnings.py | 5 ----- 3 files changed, 13 insertions(+), 10 deletions(-) (limited to 'lib/sqlalchemy/testing') diff --git a/lib/sqlalchemy/testing/fixtures.py b/lib/sqlalchemy/testing/fixtures.py index 209ea415e..ac4d3d8fa 100644 --- a/lib/sqlalchemy/testing/fixtures.py +++ b/lib/sqlalchemy/testing/fixtures.py @@ -176,7 +176,6 @@ class TablesTest(TestBase): cls.bind = cls.setup_bind() cls._tables_metadata = sa.MetaData() - cls._tables_metadata.bind = cls.bind @classmethod def _setup_once_inserts(cls): @@ -354,6 +353,12 @@ def create_session(**kw): return sa.orm.Session(config.db, **kw) +def fixture_session(**kw): + kw.setdefault("autoflush", True) + kw.setdefault("expire_on_commit", True) + return sa.orm.Session(config.db, **kw) + + class ORMTest(_ORMTest, TestBase): pass diff --git a/lib/sqlalchemy/testing/suite/test_rowcount.py b/lib/sqlalchemy/testing/suite/test_rowcount.py index f3f902abd..bb344237a 100644 --- a/lib/sqlalchemy/testing/suite/test_rowcount.py +++ b/lib/sqlalchemy/testing/suite/test_rowcount.py @@ -1,6 +1,7 @@ from sqlalchemy import bindparam from sqlalchemy import Column from sqlalchemy import Integer +from sqlalchemy import select from sqlalchemy import Sequence from sqlalchemy import String from sqlalchemy import Table @@ -51,12 +52,14 @@ class RowCountTest(fixtures.TablesTest): [{"name": n, "department": d} for n, d in data], ) - def test_basic(self): + def test_basic(self, connection): employees_table = self.tables.employees - s = employees_table.select() - r = s.execute().fetchall() + s = select( + employees_table.c.name, employees_table.c.department + ).order_by(employees_table.c.employee_id) + rows = connection.execute(s).fetchall() - assert len(r) == len(self.data) + eq_(rows, self.data) def test_update_rowcount1(self, connection): employees_table = self.tables.employees diff --git a/lib/sqlalchemy/testing/warnings.py b/lib/sqlalchemy/testing/warnings.py index c948ba66f..1b078a263 100644 --- a/lib/sqlalchemy/testing/warnings.py +++ b/lib/sqlalchemy/testing/warnings.py @@ -62,11 +62,6 @@ def setup_filters(): r"The Connection.connect\(\) method is considered legacy", # r".*DefaultGenerator.execute\(\)", # - # bound metadaa - # - r"The ``bind`` argument for schema methods that invoke SQL ", - r"The Function.bind argument", - r"The select.bind argument", # # result sets # -- cgit v1.2.1