mirror of
https://github.com/simple-login/app.git
synced 2024-09-21 01:11:29 +02:00
Fix base test class (#2152)
This commit is contained in:
parent
d8f7cb2852
commit
747dfc04bb
@ -1,5 +1,6 @@
|
||||
import os
|
||||
|
||||
from flask import testing
|
||||
|
||||
# use the tests/test.env config fle
|
||||
# flake8: noqa: E402
|
||||
@ -46,6 +47,15 @@ def flask_app():
|
||||
from app import config, constants
|
||||
|
||||
|
||||
class CustomTestClient(testing.FlaskClient):
|
||||
def open(self, *args, **kwargs):
|
||||
if isinstance(args[0], str):
|
||||
headers = kwargs.pop("headers", {})
|
||||
headers.update({constants.HEADER_ALLOW_API_COOKIES: "allow"})
|
||||
kwargs["headers"] = headers
|
||||
return super().open(*args, **kwargs)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def flask_client():
|
||||
transaction = connection.begin()
|
||||
@ -54,6 +64,7 @@ def flask_client():
|
||||
# disable rate limit during test
|
||||
config.DISABLE_RATE_LIMIT = True
|
||||
try:
|
||||
app.test_client_class = CustomTestClient
|
||||
client = app.test_client()
|
||||
client.environ_base[constants.HEADER_ALLOW_API_COOKIES] = "allow"
|
||||
yield client
|
||||
|
Loading…
Reference in New Issue
Block a user