prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  API tests using wrong tables database
  **Describe the bug**
  The django API tests are running on the `test_mathesar_db_test_database`, which differs from the `mathesar_db_test_database` tables database we should be using. As a result, we don't have a proper reference to the database being used by the API functions, which prevents us from certain operations like installing types for a test. 
  
  **Expected behavior**
  We should ensure `pytest-django` doesn't build a separate tables database.
  
  **Additional context**
  Currently blocking #276 
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `config/settings.py`
  Content:
  ```
  1 """
  2 Django settings for config project.
  3 
  4 Generated by 'django-admin startproject' using Django 3.1.7.
  5 
  6 For more information on this file, see
  7 https://docs.djangoproject.com/en/3.1/topics/settings/
  8 
  9 For the full list of settings and their values, see
  10 https://docs.djangoproject.com/en/3.1/ref/settings/
  11 """
  12 
  13 import os
  14 from pathlib import Path
  15 
  16 from decouple import Csv, config as decouple_config
  17 from dj_database_url import parse as db_url
  18 
  19 # Build paths inside the project like this: BASE_DIR / 'subdir'.
  20 BASE_DIR = Path(__file__).resolve().parent.parent
  21 
  22 # Application definition
  23 
  24 INSTALLED_APPS = [
  25     "django.contrib.admin",
  26     "django.contrib.auth",
  27     "django.contrib.contenttypes",
  28     "django.contrib.sessions",
  29     "django.contrib.messages",
  30     "django.contrib.staticfiles",
  31     "rest_framework",
  32     "django_filters",
  33     "django_property_filter",
  34     "mathesar",
  35 ]
  36 
  37 MIDDLEWARE = [
  38     "django.middleware.security.SecurityMiddleware",
  39     "django.contrib.sessions.middleware.SessionMiddleware",
  40     "django.middleware.common.CommonMiddleware",
  41     "django.middleware.csrf.CsrfViewMiddleware",
  42     "django.contrib.auth.middleware.AuthenticationMiddleware",
  43     "django.contrib.messages.middleware.MessageMiddleware",
  44     "django.middleware.clickjacking.XFrameOptionsMiddleware",
  45 ]
  46 
  47 ROOT_URLCONF = "config.urls"
  48 
  49 TEMPLATES = [
  50     {
  51         "BACKEND": "django.template.backends.django.DjangoTemplates",
  52         "DIRS": [],
  53         "APP_DIRS": True,
  54         "OPTIONS": {
  55             "context_processors": [
  56                 "config.context_processors.get_settings",
  57                 "django.template.context_processors.debug",
  58                 "django.template.context_processors.request",
  59                 "django.contrib.auth.context_processors.auth",
  60                 "django.contrib.messages.context_processors.messages",
  61             ],
  62         },
  63     },
  64 ]
  65 
  66 WSGI_APPLICATION = "config.wsgi.application"
  67 
  68 # Database
  69 # https://docs.djangoproject.com/en/3.1/ref/settings/#databases
  70 
  71 # TODO: Add to documentation that database keys should not be than 128 characters.
  72 DATABASES = {
  73     decouple_config('DJANGO_DATABASE_KEY'): decouple_config('DJANGO_DATABASE_URL', cast=db_url),
  74     decouple_config('MATHESAR_DATABASE_KEY'): decouple_config('MATHESAR_DATABASE_URL', cast=db_url)
  75 }
  76 
  77 
  78 # Quick-start development settings - unsuitable for production
  79 # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
  80 
  81 # SECURITY WARNING: keep the secret key used in production secret!
  82 SECRET_KEY = decouple_config('SECRET_KEY')
  83 
  84 # SECURITY WARNING: don't run with debug turned on in production!
  85 DEBUG = decouple_config('DEBUG', default=False, cast=bool)
  86 
  87 ALLOWED_HOSTS = decouple_config('ALLOWED_HOSTS', cast=Csv())
  88 
  89 # Password validation
  90 # https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
  91 
  92 AUTH_PASSWORD_VALIDATORS = [
  93     {
  94         "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
  95     },
  96     {
  97         "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
  98     },
  99     {
  100         "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
  101     },
  102     {
  103         "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
  104     },
  105 ]
  106 
  107 
  108 # Internationalization
  109 # https://docs.djangoproject.com/en/3.1/topics/i18n/
  110 
  111 LANGUAGE_CODE = "en-us"
  112 
  113 TIME_ZONE = "UTC"
  114 
  115 USE_I18N = True
  116 
  117 USE_L10N = True
  118 
  119 USE_TZ = True
  120 
  121 
  122 # Static files (CSS, JavaScript, Images)
  123 # https://docs.djangoproject.com/en/3.1/howto/static-files/
  124 
  125 STATIC_URL = "/static/"
  126 
  127 CLIENT_DEV_URL = "http://localhost:3000"
  128 
  129 
  130 # Media files (uploaded by the user)
  131 
  132 MEDIA_ROOT = os.path.join(BASE_DIR, '.media/')
  133 
  134 MEDIA_URL = "/media/"
  135
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/config/settings.py b/config/settings.py
  --- a/config/settings.py
  +++ b/config/settings.py
  @@ -74,6 +74,13 @@
       decouple_config('MATHESAR_DATABASE_KEY'): decouple_config('MATHESAR_DATABASE_URL', cast=db_url)
   }
   
  +# pytest-django will create a new database named 'test_{DATABASES[table_db]['NAME']}'
  +# and use it for our API tests if we don't specify DATABASES[table_db]['TEST']['NAME']
  +if decouple_config('TEST', default=False, cast=bool):
  +    DATABASES[decouple_config('MATHESAR_DATABASE_KEY')]['TEST'] = {
  +        'NAME': DATABASES[decouple_config('MATHESAR_DATABASE_KEY')]['NAME']
  +    }
  +
   
   # Quick-start development settings - unsuitable for production
   # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
  
verification_info: {"golden_diff": "diff --git a/config/settings.py b/config/settings.py\n--- a/config/settings.py\n+++ b/config/settings.py\n@@ -74,6 +74,13 @@\n     decouple_config('MATHESAR_DATABASE_KEY'): decouple_config('MATHESAR_DATABASE_URL', cast=db_url)\n }\n \n+# pytest-django will create a new database named 'test_{DATABASES[table_db]['NAME']}'\n+# and use it for our API tests if we don't specify DATABASES[table_db]['TEST']['NAME']\n+if decouple_config('TEST', default=False, cast=bool):\n+    DATABASES[decouple_config('MATHESAR_DATABASE_KEY')]['TEST'] = {\n+        'NAME': DATABASES[decouple_config('MATHESAR_DATABASE_KEY')]['NAME']\n+    }\n+\n \n # Quick-start development settings - unsuitable for production\n # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/\n", "issue": "API tests using wrong tables database\n**Describe the bug**\r\nThe django API tests are running on the `test_mathesar_db_test_database`, which differs from the `mathesar_db_test_database` tables database we should be using. As a result, we don't have a proper reference to the database being used by the API functions, which prevents us from certain operations like installing types for a test. \r\n\r\n**Expected behavior**\r\nWe should ensure `pytest-django` doesn't build a separate tables database.\r\n\r\n**Additional context**\r\nCurrently blocking #276 \r\n\n", "before_files": [{"content": "\"\"\"\nDjango settings for config project.\n\nGenerated by 'django-admin startproject' using Django 3.1.7.\n\nFor more information on this file, see\nhttps://docs.djangoproject.com/en/3.1/topics/settings/\n\nFor the full list of settings and their values, see\nhttps://docs.djangoproject.com/en/3.1/ref/settings/\n\"\"\"\n\nimport os\nfrom pathlib import Path\n\nfrom decouple import Csv, config as decouple_config\nfrom dj_database_url import parse as db_url\n\n# Build paths inside the project like this: BASE_DIR / 'subdir'.\nBASE_DIR = Path(__file__).resolve().parent.parent\n\n# Application definition\n\nINSTALLED_APPS = [\n    \"django.contrib.admin\",\n    \"django.contrib.auth\",\n    \"django.contrib.contenttypes\",\n    \"django.contrib.sessions\",\n    \"django.contrib.messages\",\n    \"django.contrib.staticfiles\",\n    \"rest_framework\",\n    \"django_filters\",\n    \"django_property_filter\",\n    \"mathesar\",\n]\n\nMIDDLEWARE = [\n    \"django.middleware.security.SecurityMiddleware\",\n    \"django.contrib.sessions.middleware.SessionMiddleware\",\n    \"django.middleware.common.CommonMiddleware\",\n    \"django.middleware.csrf.CsrfViewMiddleware\",\n    \"django.contrib.auth.middleware.AuthenticationMiddleware\",\n    \"django.contrib.messages.middleware.MessageMiddleware\",\n    \"django.middleware.clickjacking.XFrameOptionsMiddleware\",\n]\n\nROOT_URLCONF = \"config.urls\"\n\nTEMPLATES = [\n    {\n        \"BACKEND\": \"django.template.backends.django.DjangoTemplates\",\n        \"DIRS\": [],\n        \"APP_DIRS\": True,\n        \"OPTIONS\": {\n            \"context_processors\": [\n                \"config.context_processors.get_settings\",\n                \"django.template.context_processors.debug\",\n                \"django.template.context_processors.request\",\n                \"django.contrib.auth.context_processors.auth\",\n                \"django.contrib.messages.context_processors.messages\",\n            ],\n        },\n    },\n]\n\nWSGI_APPLICATION = \"config.wsgi.application\"\n\n# Database\n# https://docs.djangoproject.com/en/3.1/ref/settings/#databases\n\n# TODO: Add to documentation that database keys should not be than 128 characters.\nDATABASES = {\n    decouple_config('DJANGO_DATABASE_KEY'): decouple_config('DJANGO_DATABASE_URL', cast=db_url),\n    decouple_config('MATHESAR_DATABASE_KEY'): decouple_config('MATHESAR_DATABASE_URL', cast=db_url)\n}\n\n\n# Quick-start development settings - unsuitable for production\n# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/\n\n# SECURITY WARNING: keep the secret key used in production secret!\nSECRET_KEY = decouple_config('SECRET_KEY')\n\n# SECURITY WARNING: don't run with debug turned on in production!\nDEBUG = decouple_config('DEBUG', default=False, cast=bool)\n\nALLOWED_HOSTS = decouple_config('ALLOWED_HOSTS', cast=Csv())\n\n# Password validation\n# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators\n\nAUTH_PASSWORD_VALIDATORS = [\n    {\n        \"NAME\": \"django.contrib.auth.password_validation.UserAttributeSimilarityValidator\",\n    },\n    {\n        \"NAME\": \"django.contrib.auth.password_validation.MinimumLengthValidator\",\n    },\n    {\n        \"NAME\": \"django.contrib.auth.password_validation.CommonPasswordValidator\",\n    },\n    {\n        \"NAME\": \"django.contrib.auth.password_validation.NumericPasswordValidator\",\n    },\n]\n\n\n# Internationalization\n# https://docs.djangoproject.com/en/3.1/topics/i18n/\n\nLANGUAGE_CODE = \"en-us\"\n\nTIME_ZONE = \"UTC\"\n\nUSE_I18N = True\n\nUSE_L10N = True\n\nUSE_TZ = True\n\n\n# Static files (CSS, JavaScript, Images)\n# https://docs.djangoproject.com/en/3.1/howto/static-files/\n\nSTATIC_URL = \"/static/\"\n\nCLIENT_DEV_URL = \"http://localhost:3000\"\n\n\n# Media files (uploaded by the user)\n\nMEDIA_ROOT = os.path.join(BASE_DIR, '.media/')\n\nMEDIA_URL = \"/media/\"\n", "path": "config/settings.py"}], "after_files": [{"content": "\"\"\"\nDjango settings for config project.\n\nGenerated by 'django-admin startproject' using Django 3.1.7.\n\nFor more information on this file, see\nhttps://docs.djangoproject.com/en/3.1/topics/settings/\n\nFor the full list of settings and their values, see\nhttps://docs.djangoproject.com/en/3.1/ref/settings/\n\"\"\"\n\nimport os\nfrom pathlib import Path\n\nfrom decouple import Csv, config as decouple_config\nfrom dj_database_url import parse as db_url\n\n# Build paths inside the project like this: BASE_DIR / 'subdir'.\nBASE_DIR = Path(__file__).resolve().parent.parent\n\n# Application definition\n\nINSTALLED_APPS = [\n    \"django.contrib.admin\",\n    \"django.contrib.auth\",\n    \"django.contrib.contenttypes\",\n    \"django.contrib.sessions\",\n    \"django.contrib.messages\",\n    \"django.contrib.staticfiles\",\n    \"rest_framework\",\n    \"django_filters\",\n    \"django_property_filter\",\n    \"mathesar\",\n]\n\nMIDDLEWARE = [\n    \"django.middleware.security.SecurityMiddleware\",\n    \"django.contrib.sessions.middleware.SessionMiddleware\",\n    \"django.middleware.common.CommonMiddleware\",\n    \"django.middleware.csrf.CsrfViewMiddleware\",\n    \"django.contrib.auth.middleware.AuthenticationMiddleware\",\n    \"django.contrib.messages.middleware.MessageMiddleware\",\n    \"django.middleware.clickjacking.XFrameOptionsMiddleware\",\n]\n\nROOT_URLCONF = \"config.urls\"\n\nTEMPLATES = [\n    {\n        \"BACKEND\": \"django.template.backends.django.DjangoTemplates\",\n        \"DIRS\": [],\n        \"APP_DIRS\": True,\n        \"OPTIONS\": {\n            \"context_processors\": [\n                \"config.context_processors.get_settings\",\n                \"django.template.context_processors.debug\",\n                \"django.template.context_processors.request\",\n                \"django.contrib.auth.context_processors.auth\",\n                \"django.contrib.messages.context_processors.messages\",\n            ],\n        },\n    },\n]\n\nWSGI_APPLICATION = \"config.wsgi.application\"\n\n# Database\n# https://docs.djangoproject.com/en/3.1/ref/settings/#databases\n\n# TODO: Add to documentation that database keys should not be than 128 characters.\nDATABASES = {\n    decouple_config('DJANGO_DATABASE_KEY'): decouple_config('DJANGO_DATABASE_URL', cast=db_url),\n    decouple_config('MATHESAR_DATABASE_KEY'): decouple_config('MATHESAR_DATABASE_URL', cast=db_url)\n}\n\n# pytest-django will create a new database named 'test_{DATABASES[table_db]['NAME']}'\n# and use it for our API tests if we don't specify DATABASES[table_db]['TEST']['NAME']\nif decouple_config('TEST', default=False, cast=bool):\n    DATABASES[decouple_config('MATHESAR_DATABASE_KEY')]['TEST'] = {\n        'NAME': DATABASES[decouple_config('MATHESAR_DATABASE_KEY')]['NAME']\n    }\n\n\n# Quick-start development settings - unsuitable for production\n# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/\n\n# SECURITY WARNING: keep the secret key used in production secret!\nSECRET_KEY = decouple_config('SECRET_KEY')\n\n# SECURITY WARNING: don't run with debug turned on in production!\nDEBUG = decouple_config('DEBUG', default=False, cast=bool)\n\nALLOWED_HOSTS = decouple_config('ALLOWED_HOSTS', cast=Csv())\n\n# Password validation\n# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators\n\nAUTH_PASSWORD_VALIDATORS = [\n    {\n        \"NAME\": \"django.contrib.auth.password_validation.UserAttributeSimilarityValidator\",\n    },\n    {\n        \"NAME\": \"django.contrib.auth.password_validation.MinimumLengthValidator\",\n    },\n    {\n        \"NAME\": \"django.contrib.auth.password_validation.CommonPasswordValidator\",\n    },\n    {\n        \"NAME\": \"django.contrib.auth.password_validation.NumericPasswordValidator\",\n    },\n]\n\n\n# Internationalization\n# https://docs.djangoproject.com/en/3.1/topics/i18n/\n\nLANGUAGE_CODE = \"en-us\"\n\nTIME_ZONE = \"UTC\"\n\nUSE_I18N = True\n\nUSE_L10N = True\n\nUSE_TZ = True\n\n\n# Static files (CSS, JavaScript, Images)\n# https://docs.djangoproject.com/en/3.1/howto/static-files/\n\nSTATIC_URL = \"/static/\"\n\nCLIENT_DEV_URL = \"http://localhost:3000\"\n\n\n# Media files (uploaded by the user)\n\nMEDIA_ROOT = os.path.join(BASE_DIR, '.media/')\n\nMEDIA_URL = \"/media/\"\n", "path": "config/settings.py"}]}