From: CaselIT Date: Mon, 28 Feb 2022 23:21:17 +0000 (+0100) Subject: fix failing test on windows after sqlite switched to queuepool by default X-Git-Tag: rel_1_7_7~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=721b28ce889e63e49b8be1a1bd62b7d3bb3b7526;p=thirdparty%2Fsqlalchemy%2Falembic.git fix failing test on windows after sqlite switched to queuepool by default Change-Id: Iec2b2ae9c2df9592988fa2239b768d1919eec297 --- diff --git a/alembic/testing/env.py b/alembic/testing/env.py index 29470854..13d29ff9 100644 --- a/alembic/testing/env.py +++ b/alembic/testing/env.py @@ -91,10 +91,12 @@ config = context.config f.write(txt) -def _sqlite_file_db(tempname="foo.db", future=False): +def _sqlite_file_db(tempname="foo.db", future=False, scope=None, **options): dir_ = os.path.join(_get_staging_directory(), "scripts") url = "sqlite:///%s/%s" % (dir_, tempname) - return testing_util.testing_engine(url=url, future=future) + if scope and util.sqla_14: + options["scope"] = scope + return testing_util.testing_engine(url=url, future=future, options=options) def _sqlite_testing_config(sourceless=False, future=False): diff --git a/setup.cfg b/setup.cfg index 0bc27621..9fe48346 100644 --- a/setup.cfg +++ b/setup.cfg @@ -122,6 +122,8 @@ oracle8=oracle://scott:tiger@127.0.0.1:1521/?use_ansi=0 [tool:pytest] addopts= --tb native -v -r sfxX -p no:warnings -p no:logging --maxfail=25 python_files=tests/test_*.py +markers = + backend: tests that should run on all backends; typically dialect-sensitive [mypy] show_error_codes = True diff --git a/tests/test_command.py b/tests/test_command.py index 680a7fb6..af507cbd 100644 --- a/tests/test_command.py +++ b/tests/test_command.py @@ -87,7 +87,7 @@ try: context.run_migrations() finally: connection.close() - + engine.dispose() """ ) @@ -204,7 +204,7 @@ finally: class CurrentTest(_BufMixin, TestBase): @classmethod def setup_class(cls): - cls.bind = _sqlite_file_db() + cls.bind = _sqlite_file_db(scope="class") cls.env = env = staging_env() cls.cfg = _sqlite_testing_config() cls.a1 = env.generate_revision("a1", "a1") @@ -309,6 +309,7 @@ try: context.run_migrations() finally: connection.close() + engine.dispose() """ % (version_table_pk,) @@ -1192,7 +1193,7 @@ class CommandLineTest(TestBase): class EnureVersionTest(TestBase): @classmethod def setup_class(cls): - cls.bind = _sqlite_file_db() + cls.bind = _sqlite_file_db(scope="class") cls.env = staging_env() cls.cfg = _sqlite_testing_config() diff --git a/tests/test_script_consumption.py b/tests/test_script_consumption.py index 2f9f7481..d478ae1b 100644 --- a/tests/test_script_consumption.py +++ b/tests/test_script_consumption.py @@ -6,6 +6,7 @@ import re import textwrap import sqlalchemy as sa +from sqlalchemy import pool from alembic import command from alembic import testing @@ -116,18 +117,9 @@ class PatchEnvironment: @testing.combinations( - ( - False, - True, - ), - ( - True, - False, - ), - ( - True, - True, - ), + (False, True), + (True, False), + (True, True), argnames="transactional_ddl,transaction_per_migration", id_="rr", ) @@ -141,7 +133,9 @@ class ApplyVersionsFunctionalTest(PatchEnvironment, TestBase): branched_connection = False def setUp(self): - self.bind = _sqlite_file_db(future=self.future) + self.bind = _sqlite_file_db( + future=self.future, poolclass=pool.NullPool + ) self.env = staging_env(sourceless=self.sourceless) self.cfg = _sqlite_testing_config( sourceless=self.sourceless, future=self.future @@ -802,7 +796,7 @@ class IgnoreFilesTest(TestBase): sourceless = False def setUp(self): - self.bind = _sqlite_file_db() + self.bind = _sqlite_file_db(poolclass=pool.NullPool) self.env = staging_env(sourceless=self.sourceless) self.cfg = _sqlite_testing_config(sourceless=self.sourceless)