Speed up tests

This commit is contained in:
2024-12-12 17:37:00 +01:00
parent cfe6e27a7a
commit 276a9b734a
6 changed files with 7 additions and 0 deletions

View File

View File

@ -1,40 +0,0 @@
from __future__ import annotations
import logging
from typing import TYPE_CHECKING
import pytest
if TYPE_CHECKING:
from django.conf import LazySettings
logger: logging.Logger = logging.getLogger(__name__)
@pytest.fixture(autouse=True)
def _media_root(
settings: LazySettings,
tmpdir_factory: pytest.TempPathFactory,
) -> None:
"""Forces django to save media files into temp folder."""
settings.MEDIA_ROOT = tmpdir_factory.mktemp("media", numbered=True)
logger.info("Testing: Media root is set to %s", settings.MEDIA_ROOT)
@pytest.fixture(autouse=True)
def _password_hashers(settings: LazySettings) -> None:
"""Forces django to use fast password hashers for tests."""
settings.PASSWORD_HASHERS = [
"django.contrib.auth.hashers.MD5PasswordHasher",
]
logger.info("Testing: Password hashers are set to %s", settings.PASSWORD_HASHERS)
@pytest.fixture(autouse=True)
def _debug(settings: LazySettings) -> None:
"""Sets proper DEBUG and TEMPLATE debug mode for coverage."""
settings.DEBUG = False
for template in settings.TEMPLATES:
template["OPTIONS"]["debug"] = True
logger.info("Testing: DEBUG is set to %s", settings.DEBUG)

7396
core/tests/response.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,23 +0,0 @@
"""Tests for the views in the core app."""
from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
from django.http import HttpResponse
from django.urls import reverse
if TYPE_CHECKING:
from django.test import Client
from django.test.client import _MonkeyPatchedWSGIResponse # type: ignore[import]
@pytest.mark.django_db
def test_index_view(client: Client) -> None:
"""Test index view."""
url: str = reverse(viewname="index")
response: _MonkeyPatchedWSGIResponse = client.get(url)
assert isinstance(response, HttpResponse)
assert response.status_code == 200