Skip to content

Commit ec9d832

Browse files
authored
tests: settings: use explicit name for DB (that should not get used) (#805)
1 parent 1bc72fd commit ec9d832

6 files changed

+9
-15
lines changed

pytest_django_test/settings_base.py

-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import os
2-
31
import django
42

53
ROOT_URLCONF = "pytest_django_test.urls"
@@ -14,10 +12,6 @@
1412
STATIC_URL = "/static/"
1513
SECRET_KEY = "foobar"
1614

17-
# Used to construct unique test database names to allow detox to run multiple
18-
# versions at the same time
19-
db_suffix = "_%s" % os.getuid()
20-
2115
MIDDLEWARE = [
2216
"django.contrib.sessions.middleware.SessionMiddleware",
2317
"django.middleware.common.CommonMiddleware",

pytest_django_test/settings_mysql_innodb.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from .settings_base import * # noqa: F403
1+
from .settings_base import * # noqa: F401 F403
22

33
DATABASES = {
44
"default": {
55
"ENGINE": "django.db.backends.mysql",
6-
"NAME": "pytest_django" + db_suffix, # noqa: F405
6+
"NAME": "pytest_django_should_never_get_accessed",
77
"HOST": "localhost",
88
"USER": "root",
99
"OPTIONS": {"init_command": "SET default_storage_engine=InnoDB"},

pytest_django_test/settings_mysql_myisam.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from pytest_django_test.settings_base import * # noqa: F403
1+
from .settings_base import * # noqa: F401 F403
22

33
DATABASES = {
44
"default": {
55
"ENGINE": "django.db.backends.mysql",
6-
"NAME": "pytest_django" + db_suffix, # noqa: F405
6+
"NAME": "pytest_django_should_never_get_accessed",
77
"HOST": "localhost",
88
"USER": "root",
99
"OPTIONS": {"init_command": "SET default_storage_engine=MyISAM"},

pytest_django_test/settings_postgres.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from pytest_django_test.settings_base import * # noqa
1+
from .settings_base import * # noqa: F401 F403
22

33
# PyPy compatibility
44
try:
@@ -12,7 +12,7 @@
1212
DATABASES = {
1313
"default": {
1414
"ENGINE": "django.db.backends.postgresql_psycopg2",
15-
"NAME": "pytest_django" + db_suffix, # noqa
15+
"NAME": "pytest_django_should_never_get_accessed",
1616
"HOST": "localhost",
1717
"USER": "",
1818
}

pytest_django_test/settings_sqlite.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from .settings_base import * # noqa
1+
from .settings_base import * # noqa: F401 F403
22

33
DATABASES = {
44
"default": {

pytest_django_test/settings_sqlite_file.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import tempfile
22

3-
from pytest_django_test.settings_base import * # noqa
3+
from .settings_base import * # noqa: F401 F403
44

55
# This is a SQLite configuration, which uses a file based database for
66
# tests (via setting TEST_NAME / TEST['NAME']).
@@ -11,7 +11,7 @@
1111
DATABASES = {
1212
"default": {
1313
"ENGINE": "django.db.backends.sqlite3",
14-
"NAME": "/should_never_be_accessed",
14+
"NAME": "/pytest_django_should_never_get_accessed",
1515
"TEST": {"NAME": _filename},
1616
}
1717
}

0 commit comments

Comments
 (0)