Skip to content

Commit 96c72c4

Browse files
committedJun 30, 2017
Disable Alembic migrations during testing
A side-effect of initializing the Alembic database schema migration system is that it creates directories on the file system. This breaks the test suite in some environments and bloats test startup time. Since we don't need Alembic to run our acceptance tests, we replace Alembic with a stub.
1 parent 36a8071 commit 96c72c4

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed
 

‎tests/conftest.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,21 @@ def versionfile(tmpdir):
4343

4444

4545
@pytest.fixture
46-
def app(versionfile, docker_env_vars):
46+
def disable_migrations(monkeypatch):
47+
"""Disable the Alembic DB migrations system in the app during testing."""
48+
49+
class StubAlembic:
50+
def __init__(self):
51+
pass
52+
53+
def init_app(self, app):
54+
pass
55+
56+
monkeypatch.setattr('landoapi.app.alembic', StubAlembic())
57+
58+
59+
@pytest.fixture
60+
def app(versionfile, docker_env_vars, disable_migrations):
4761
"""Needed for pytest-flask."""
4862
app = create_app(versionfile.strpath)
4963
return app.app

0 commit comments

Comments
 (0)
Failed to load comments.