Skip to content

Commit ab6f459

Browse files
committed
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
1 parent 22b1085 commit ab6f459

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

noxfile.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def _tests(
104104

105105
# for sqlalchemy == "default", the alembic install will install
106106
# current released SQLAlchemy version as a dependency
107+
shutil.rmtree("build/", ignore_errors=True)
107108
if coverage:
108109
session.install("-e", ".")
109110
else:
@@ -201,6 +202,7 @@ def _tests(
201202
def mypy_check(session: nox.Session) -> None:
202203
"""Run mypy type checking."""
203204

205+
shutil.rmtree("build/", ignore_errors=True)
204206
session.install(*nox.project.dependency_groups(pyproject, "mypy"))
205207

206208
session.install("-e", ".")

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ sqlite=sqlite:///:memory:
2929
sqlite_file=sqlite:///querytest.db
3030
postgresql=postgresql://scott:tiger@127.0.0.1:5432/test
3131
psycopg=postgresql+psycopg://scott:tiger@127.0.0.1:5432/test
32+
psycopg2=postgresql+psycopg2://scott:tiger@127.0.0.1:5432/test
3233
mysql=mysql://scott:tiger@127.0.0.1:3306/test?charset=utf8mb4
3334
mariadb=mariadb://scott:tiger@127.0.0.1:3306/test?charset=utf8mb4
3435
mssql=mssql+pyodbc://scott:tiger^5HHH@mssql2022:1433/test?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes&Encrypt=Optional

tests/test_bulk_insert.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def test_bulk_insert(self):
7272
)
7373

7474
def test_bulk_insert_wrong_cols(self):
75-
context = op_fixture("postgresql")
75+
context = op_fixture("postgresql+psycopg2")
7676
t1 = table(
7777
"ins_table",
7878
column("id", Integer),
@@ -92,14 +92,14 @@ def test_bulk_insert_no_rows(self):
9292
context.assert_()
9393

9494
def test_bulk_insert_pg(self):
95-
context = self._test_bulk_insert("postgresql", False)
95+
context = self._test_bulk_insert("postgresql+psycopg2", False)
9696
context.assert_(
9797
"INSERT INTO ins_table (id, v1, v2) "
9898
"VALUES (%(id)s, %(v1)s, %(v2)s)"
9999
)
100100

101101
def test_bulk_insert_pg_single(self):
102-
context = self._test_bulk_insert_single("postgresql", False)
102+
context = self._test_bulk_insert_single("postgresql+psycopg2", False)
103103
context.assert_(
104104
"INSERT INTO ins_table (id, v1, v2) "
105105
"VALUES (%(id)s, %(v1)s, %(v2)s)"

0 commit comments

Comments
 (0)