-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconftest.py
36 lines (31 loc) · 1.17 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
import pytest
from django.conf import global_settings, settings
from django.test.utils import setup_test_environment
pytest_plugins = ["pytester", "django_utils_lib.testing.pytest_plugin"]
def configure_django_settings():
if settings.configured:
return
settings.configure(
default_settings=global_settings,
DATABASES={
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": ":memory:",
}
},
INSTALLED_APPS=[
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
],
)
def pytest_configure():
# TODO: This is rather hacky and it would be great to find a cleaner way to
# do this. However, the pytest-django fixture we are disabling here is hard
# to alter in any other way, especially as it uses session-level autouse
pytest.MonkeyPatch().setattr("pytest_django.plugin.django_test_environment", lambda: None)
configure_django_settings()
setup_test_environment(debug=False)