]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Fix test failures under Windows
authorFederico Caselli <cfederico87@gmail.com>
Tue, 31 Dec 2019 01:29:33 +0000 (20:29 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 31 Dec 2019 01:37:45 +0000 (20:37 -0500)
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
(cherry picked from commit f461d710f9f848029603cf76f7c26725afdea11e)

doc/build/changelog/unreleased_13/4946.rst [new file with mode: 0644]
test/dialect/test_sqlite.py
test/ext/test_horizontal_shard.py

diff --git a/doc/build/changelog/unreleased_13/4946.rst b/doc/build/changelog/unreleased_13/4946.rst
new file mode 100644 (file)
index 0000000..f0946f4
--- /dev/null
@@ -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.
+
index 931631308c202a53089edc10a266bb4f47885ad3..01a0a54371d9e4478d1aff82ba89dafd08e07cb4 100644 (file)
@@ -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
@@ -711,40 +712,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"),
index affd7112c6eab9aec99d10a52c82cdb65ca5a11e..16694c86f5dfa5eb16d3cb9b1cd91b31592eb734 100644 (file)
@@ -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
@@ -568,6 +569,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))