-
-
Notifications
You must be signed in to change notification settings - Fork 816
/
Copy pathconftest.py
40 lines (32 loc) · 1.12 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import pytest
from django.conf import settings
def pytest_configure():
settings.configure(
DATABASES={
"default": {
"ENGINE": "django.db.backends.sqlite3",
# Override Django’s default behaviour of using an in-memory database
# in tests for SQLite, since that avoids connection.close() working.
"TEST": {"NAME": "test_db.sqlite3"},
}
},
INSTALLED_APPS=[
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.admin",
"channels",
],
SECRET_KEY="Not_a_secret_key",
)
def pytest_generate_tests(metafunc):
if "samesite" in metafunc.fixturenames:
metafunc.parametrize("samesite", ["Strict", "None"], indirect=True)
@pytest.fixture
def samesite(request, settings):
"""Set samesite flag to strict."""
settings.SESSION_COOKIE_SAMESITE = request.param
@pytest.fixture
def samesite_invalid(settings):
"""Set samesite flag to strict."""
settings.SESSION_COOKIE_SAMESITE = "Hello"