Compare commits

...

3 Commits

Author SHA1 Message Date
Trenton H
1f461a7ee4 Enables the fixture again 2025-09-10 09:23:35 -07:00
Trenton H
a2ce0af79f Get initial durations of all tests 2025-09-10 09:10:07 -07:00
Trenton H
ba40626838 Experiment with disabling whitenoise middleware 2025-09-10 08:52:02 -07:00
2 changed files with 24 additions and 1 deletions

View File

@@ -241,7 +241,7 @@ addopts = [
"--numprocesses=auto", "--numprocesses=auto",
"--maxprocesses=16", "--maxprocesses=16",
"--quiet", "--quiet",
"--durations=50", "--durations=0",
"--junitxml=junit.xml", "--junitxml=junit.xml",
"-o junit_family=legacy", "-o junit_family=legacy",
] ]
@@ -249,6 +249,10 @@ norecursedirs = [ "src/locale/", ".venv/", "src-ui/" ]
DJANGO_SETTINGS_MODULE = "paperless.settings" DJANGO_SETTINGS_MODULE = "paperless.settings"
markers = [
"use_whitenoise: mark test to run with Whitenoise middleware enabled",
]
[tool.pytest_env] [tool.pytest_env]
PAPERLESS_DISABLE_DBHANDLER = "true" PAPERLESS_DISABLE_DBHANDLER = "true"
PAPERLESS_CACHE_BACKEND = "django.core.cache.backends.locmem.LocMemCache" PAPERLESS_CACHE_BACKEND = "django.core.cache.backends.locmem.LocMemCache"

View File

@@ -28,3 +28,22 @@ def authenticated_rest_api_client(rest_api_client: APIClient):
user = UserModel.objects.create_user(username="testuser", password="password") user = UserModel.objects.create_user(username="testuser", password="password")
rest_api_client.force_authenticate(user=user) rest_api_client.force_authenticate(user=user)
yield rest_api_client yield rest_api_client
@pytest.fixture(autouse=True)
def configure_whitenoise_middleware(request, settings):
"""
By default, remove Whitenoise middleware from tests.
Only include it when test is marked with @pytest.mark.use_whitenoise
"""
# Check if the test is marked to use whitenoise
use_whitenoise_marker = request.node.get_closest_marker("use_whitenoise")
if not use_whitenoise_marker:
# Filter out whitenoise middleware using pytest-django's settings fixture
middleware_without_whitenoise = [
mw for mw in settings.MIDDLEWARE if "whitenoisemiddleware" not in mw.lower()
]
settings.MIDDLEWARE = middleware_without_whitenoise
yield