placeholder-api/tests/conftest.py

28 lines
755 B
Python

import pytest
from app import create_app
from app.extensions import cache, limiter
@pytest.fixture
def app(monkeypatch, request):
# Ignore the host's deployment setting; proxy tests opt in via indirect parameters.
monkeypatch.delenv("PROXY_PASS", raising=False)
if getattr(request, "param", False):
monkeypatch.setenv("PROXY_PASS", "1")
application = create_app()
application.config["TESTING"] = True
# Keep cached images and rate-limit counters isolated between tests.
with application.app_context():
cache.clear()
limiter.reset()
yield application
with application.app_context():
cache.clear()
limiter.reset()
@pytest.fixture
def client(app):
return app.test_client()