summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2020-01-01 00:18:31 +0000
committerGerrit Code Review <gerrit@bbpush.zzzcomputing.com>2020-01-01 00:18:31 +0000
commitcf126b49e7c88a0eb58920e2e85b628651fbcfd2 (patch)
tree2786d618704ddcd30427cad9c7a2a92e453d7344
parent7210595a79cd33b3b0da48db2806856fe018f495 (diff)
parentae354ce347336ba7efc1222c161e0da80314b485 (diff)
downloadsqlalchemy-cf126b49e7c88a0eb58920e2e85b628651fbcfd2.tar.gz
Merge "Fix test failures under Windows"
-rw-r--r--doc/build/changelog/unreleased_13/4946.rst8
-rw-r--r--test/dialect/test_sqlite.py66
-rw-r--r--test/ext/test_horizontal_shard.py3
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))