Enable debug mode in tests.

Debug mode allows route integration tests to raise explicit exceptions on
errors, instead of returning error pages. Some portions of the test
suite need to be able to ignore exceptions (the response is not under
test) so they use a separate pytest fixture version of the app and
client that are configured with debug disabled, as it would be in
production.
This commit is contained in:
dandds
2019-08-29 13:07:24 -04:00
parent 094e44a6b0
commit 883947b75f
8 changed files with 82 additions and 32 deletions

View File

@@ -28,13 +28,7 @@ dictConfig({"version": 1, "handlers": {"wsgi": {"class": "logging.NullHandler"}}
@pytest.fixture(scope="session")
def app(request):
upload_dir = TemporaryDirectory()
config = make_config()
config.update(
{"STORAGE_CONTAINER": upload_dir.name, "CRL_STORAGE_PROVIDER": "LOCAL"}
)
_app = make_app(config)
ctx = _app.app_context()
@@ -42,11 +36,27 @@ def app(request):
yield _app
upload_dir.cleanup()
ctx.pop()
@pytest.fixture(scope="function")
def no_debug_app(request):
config = make_config(direct_config={"DEBUG": False})
_app = make_app(config)
ctx = _app.app_context()
ctx.push()
yield _app
ctx.pop()
@pytest.fixture(scope="function")
def no_debug_client(no_debug_app):
yield no_debug_app.test_client()
def apply_migrations():
"""Applies all alembic migrations."""
alembic_config = os.path.join(os.path.dirname(__file__), "../", "alembic.ini")