From: Mike Bayer Date: Tue, 16 Dec 2025 03:01:06 +0000 (-0500) Subject: force the driver level on the bulk insert PG tests X-Git-Tag: rel_1_18_0~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ab6f459ea053663fdd54ae30c2e7e3f1d60850c1;p=thirdparty%2Fsqlalchemy%2Falembic.git force the driver level on the bulk insert PG tests this changes to use the psycopg2 dialect in all cases even if the default for postgresql changes. this is to prepare for SQLAlchemy moving to psycopg as the default dialect. I had hoped to move these tests to use psycopg and test for bind casts, however, we are still running tests against SQLAlchemy 1.4 which does not have the psycopg dialect. so stick with psycopg2 for now. also adds an rmtree for build/ as apparently pip install is re-using this directory if it's there from a previous build, and the artfacts left over from the gerrit for "plugins" is interfering with the stubs generation. We really should find a way to make the stub generation / testing more robust as it breaks much too easily and without an easy way to tell why. Change-Id: Ibdab43a2cda5ec4f697d35c8a5f090aa56492703 --- diff --git a/noxfile.py b/noxfile.py index 2752e8b5..6a470503 100644 --- a/noxfile.py +++ b/noxfile.py @@ -104,6 +104,7 @@ def _tests( # for sqlalchemy == "default", the alembic install will install # current released SQLAlchemy version as a dependency + shutil.rmtree("build/", ignore_errors=True) if coverage: session.install("-e", ".") else: @@ -201,6 +202,7 @@ def _tests( def mypy_check(session: nox.Session) -> None: """Run mypy type checking.""" + shutil.rmtree("build/", ignore_errors=True) session.install(*nox.project.dependency_groups(pyproject, "mypy")) session.install("-e", ".") diff --git a/setup.cfg b/setup.cfg index 37c6e86a..eb2676ce 100644 --- a/setup.cfg +++ b/setup.cfg @@ -29,6 +29,7 @@ sqlite=sqlite:///:memory: sqlite_file=sqlite:///querytest.db postgresql=postgresql://scott:tiger@127.0.0.1:5432/test psycopg=postgresql+psycopg://scott:tiger@127.0.0.1:5432/test +psycopg2=postgresql+psycopg2://scott:tiger@127.0.0.1:5432/test mysql=mysql://scott:tiger@127.0.0.1:3306/test?charset=utf8mb4 mariadb=mariadb://scott:tiger@127.0.0.1:3306/test?charset=utf8mb4 mssql=mssql+pyodbc://scott:tiger^5HHH@mssql2022:1433/test?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes&Encrypt=Optional diff --git a/tests/test_bulk_insert.py b/tests/test_bulk_insert.py index 1ad5b967..0841c9a9 100644 --- a/tests/test_bulk_insert.py +++ b/tests/test_bulk_insert.py @@ -72,7 +72,7 @@ class BulkInsertTest(TestBase): ) def test_bulk_insert_wrong_cols(self): - context = op_fixture("postgresql") + context = op_fixture("postgresql+psycopg2") t1 = table( "ins_table", column("id", Integer), @@ -92,14 +92,14 @@ class BulkInsertTest(TestBase): context.assert_() def test_bulk_insert_pg(self): - context = self._test_bulk_insert("postgresql", False) + context = self._test_bulk_insert("postgresql+psycopg2", False) context.assert_( "INSERT INTO ins_table (id, v1, v2) " "VALUES (%(id)s, %(v1)s, %(v2)s)" ) def test_bulk_insert_pg_single(self): - context = self._test_bulk_insert_single("postgresql", False) + context = self._test_bulk_insert_single("postgresql+psycopg2", False) context.assert_( "INSERT INTO ins_table (id, v1, v2) " "VALUES (%(id)s, %(v1)s, %(v2)s)"