File: conftest.py

package info (click to toggle)
python-djangorestframework-yaml 3.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 268 kB
  • sloc: python: 483; makefile: 11
file content (28 lines) | stat: -rw-r--r-- 612 bytes parent folder | download
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
"""
Pytest configuration file.

This file is automatically loaded by pytest when running tests.
See https://docs.pytest.org/en/latest/reference.html#configuration-options
for more information.
"""


def pytest_configure() -> None:
    """Configure Django settings before tests run."""
    from django.conf import settings

    settings.configure(
        DATABASES={
            "default": {
                "ENGINE": "django.db.backends.sqlite3",
                "NAME": ":memory:",
            },
        },
    )

    try:
        import django

        django.setup()
    except AttributeError:
        pass