diff options
| author | Federico Caselli <cfederico87@gmail.com> | 2019-12-30 20:29:33 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-12-31 16:13:51 -0500 |
| commit | ae354ce347336ba7efc1222c161e0da80314b485 (patch) | |
| tree | 7b4ff4ca87ee40148b3b4855d1ffc739eca121ce | |
| parent | 65428cf95023a462ec452d7c6a1a6aff7c4c20a4 (diff) | |
| download | sqlalchemy-ae354ce347336ba7efc1222c161e0da80314b485.tar.gz | |
Fix test failures under Windows
Fixed a few test failures which would occur on Windows due to SQLite file
locking issues, as well as some timing issues in connection pool related
tests; pull request courtesy Federico Caselli.
Note the pool related issues were fixed by Mike in
I1a7162e67912d22c135fa517b687a073f8fd9151 but are being ticketed
here.
Fixes: #4946
Closes: #5055
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5055
Pull-request-sha: 36925573aff828bbdd725a4fed5394e06c775a98
Change-Id: Ic53ec82f5d588d0e26a2d033a17c6109900d7f63
| -rw-r--r-- | doc/build/changelog/unreleased_13/4946.rst | 8 | ||||
| -rw-r--r-- | test/dialect/test_sqlite.py | 66 | ||||
| -rw-r--r-- | test/ext/test_horizontal_shard.py | 3 |
3 files changed, 46 insertions, 31 deletions
diff --git a/doc/build/changelog/unreleased_13/4946.rst b/doc/build/changelog/unreleased_13/4946.rst new file mode 100644 index 000000000..f0946f439 --- /dev/null +++ b/doc/build/changelog/unreleased_13/4946.rst @@ -0,0 +1,8 @@ +.. change:: + :tags: bug, tests + :tickets: 4946 + + Fixed a few test failures which would occur on Windows due to SQLite file + locking issues, as well as some timing issues in connection pool related + tests; pull request courtesy Federico Caselli. + diff --git a/test/dialect/test_sqlite.py b/test/dialect/test_sqlite.py index ec88277a6..da349c1f8 100644 --- a/test/dialect/test_sqlite.py +++ b/test/dialect/test_sqlite.py @@ -43,6 +43,7 @@ from sqlalchemy.testing import assert_raises from sqlalchemy.testing import assert_raises_message from sqlalchemy.testing import AssertsCompiledSQL from sqlalchemy.testing import AssertsExecutionResults +from sqlalchemy.testing import combinations from sqlalchemy.testing import engines from sqlalchemy.testing import eq_ from sqlalchemy.testing import expect_warnings @@ -722,40 +723,43 @@ class DialectTest(fixtures.TestBase, AssertsExecutionResults): e = create_engine("sqlite+pysqlite:///foo.db") assert e.pool.__class__ is pool.NullPool - def test_connect_args(self): + @combinations( + ( + "sqlite:///foo.db", # file path is absolute + ([os.path.abspath("foo.db")], {}), + ), + ( + "sqlite:////abs/path/to/foo.db", + ([os.path.abspath("/abs/path/to/foo.db")], {}), + ), + ("sqlite://", ([":memory:"], {})), + ( + "sqlite:///?check_same_thread=true", + ([":memory:"], {"check_same_thread": True}), + ), + ( + "sqlite:///file:path/to/database?" + "check_same_thread=true&timeout=10&mode=ro&nolock=1&uri=true", + ( + ["file:path/to/database?mode=ro&nolock=1"], + {"check_same_thread": True, "timeout": 10.0, "uri": True}, + ), + ), + ( + "sqlite:///file:path/to/database?" "mode=ro&uri=true", + (["file:path/to/database?mode=ro"], {"uri": True}), + ), + ( + "sqlite:///file:path/to/database?uri=true", + (["file:path/to/database"], {"uri": True}), + ), + ) + def test_connect_args(self, url, expected): """test create_connect_args scenarios including support for uri=True""" d = pysqlite_dialect.dialect() - for url, expected in [ - ( - "sqlite:///foo.db", # file path is absolute - ([os.path.abspath("foo.db")], {}), - ), - ("sqlite:////abs/path/to/foo.db", (["/abs/path/to/foo.db"], {})), - ("sqlite://", ([":memory:"], {})), - ( - "sqlite:///?check_same_thread=true", - ([":memory:"], {"check_same_thread": True}), - ), - ( - "sqlite:///file:path/to/database?" - "check_same_thread=true&timeout=10&mode=ro&nolock=1&uri=true", - ( - ["file:path/to/database?mode=ro&nolock=1"], - {"check_same_thread": True, "timeout": 10.0, "uri": True}, - ), - ), - ( - "sqlite:///file:path/to/database?" "mode=ro&uri=true", - (["file:path/to/database?mode=ro"], {"uri": True}), - ), - ( - "sqlite:///file:path/to/database?uri=true", - (["file:path/to/database"], {"uri": True}), - ), - ]: - url = make_url(url) - eq_(d.create_connect_args(url), expected) + url = make_url(url) + eq_(d.create_connect_args(url), expected) @testing.combinations( ("no_persisted", "ignore"), diff --git a/test/ext/test_horizontal_shard.py b/test/ext/test_horizontal_shard.py index e292cb2b0..f78f1ff06 100644 --- a/test/ext/test_horizontal_shard.py +++ b/test/ext/test_horizontal_shard.py @@ -29,6 +29,7 @@ from sqlalchemy.testing import eq_ from sqlalchemy.testing import fixtures from sqlalchemy.testing import provision from sqlalchemy.testing.engines import testing_engine +from sqlalchemy.testing.engines import testing_reaper # TODO: ShardTest can be turned into a base for further subclasses @@ -619,6 +620,8 @@ class LazyLoadIdentityKeyTest(fixtures.DeclarativeMappedTest): def teardown(self): for db in self.dbs: db.connect().invalidate() + + testing_reaper.close_all() for i in range(1, 3): os.remove("shard%d_%s.db" % (i, provision.FOLLOWER_IDENT)) |
