summaryrefslogtreecommitdiff
path: root/tests/apps/tests.py
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2021-09-16 09:06:40 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-09-20 21:23:01 +0200
commit75d6c4ae6df93c4c4d8621aced3a180afa18a6cb (patch)
treea446318521173eadf0067e57a9b02c06ed9062d4 /tests/apps/tests.py
parentd25710a625fbb6dbb047c159417f796102fd721a (diff)
Refs #31180 -- Removed default_app_config application configuration variable per deprecation timeline.
Diffstat (limited to 'tests/apps/tests.py')
-rw-r--r--tests/apps/tests.py114
1 files changed, 1 insertions, 113 deletions
diff --git a/tests/apps/tests.py b/tests/apps/tests.py
index a8a93ce683..46f118ab04 100644
--- a/tests/apps/tests.py
+++ b/tests/apps/tests.py
@@ -5,18 +5,9 @@ from django.apps.registry import Apps
from django.contrib.admin.models import LogEntry
from django.core.exceptions import AppRegistryNotReady, ImproperlyConfigured
from django.db import models
-from django.test import SimpleTestCase, ignore_warnings, override_settings
+from django.test import SimpleTestCase, override_settings
from django.test.utils import extend_sys_path, isolate_apps
-from django.utils.deprecation import RemovedInDjango41Warning
-from .explicit_default_config_app.apps import ExplicitDefaultConfig
-from .explicit_default_config_empty_apps import ExplicitDefaultConfigEmptyApps
-from .explicit_default_config_mismatch_app.not_apps import (
- ExplicitDefaultConfigMismatch,
-)
-from .explicit_default_config_without_apps import (
- ExplicitDefaultConfigWithoutApps,
-)
from .models import SoAlternative, TotallyNormal, new_apps
from .one_config_app.apps import OneConfig
from .two_configs_one_default_app.apps import TwoConfig
@@ -511,106 +502,3 @@ class NamespacePackageAppTests(SimpleTestCase):
with self.settings(INSTALLED_APPS=['nsapp.apps.NSAppConfig']):
app_config = apps.get_app_config('nsapp')
self.assertEqual(app_config.path, self.app_path)
-
-
-class DeprecationTests(SimpleTestCase):
- @ignore_warnings(category=RemovedInDjango41Warning)
- def test_explicit_default_app_config(self):
- with self.settings(INSTALLED_APPS=['apps.explicit_default_config_app']):
- config = apps.get_app_config('explicit_default_config_app')
- self.assertIsInstance(config, ExplicitDefaultConfig)
-
- def test_explicit_default_app_config_warning(self):
- """
- Load an app that specifies a default AppConfig class matching the
- autodetected one.
- """
- msg = (
- "'apps.explicit_default_config_app' defines default_app_config = "
- "'apps.explicit_default_config_app.apps.ExplicitDefaultConfig'. "
- "Django now detects this configuration automatically. You can "
- "remove default_app_config."
- )
- with self.assertRaisesMessage(RemovedInDjango41Warning, msg):
- with self.settings(INSTALLED_APPS=['apps.explicit_default_config_app']):
- pass
- with ignore_warnings(category=RemovedInDjango41Warning):
- with self.settings(INSTALLED_APPS=['apps.explicit_default_config_app']):
- self.assertIsInstance(
- apps.get_app_config('explicit_default_config_app'),
- ExplicitDefaultConfig,
- )
-
- def test_explicit_default_app_config_mismatch(self):
- """
- Load an app that specifies a default AppConfig class not matching the
- autodetected one.
- """
- msg = (
- "'apps.explicit_default_config_mismatch_app' defines "
- "default_app_config = 'apps.explicit_default_config_mismatch_app."
- "not_apps.ExplicitDefaultConfigMismatch'. However, Django's "
- "automatic detection picked another configuration, 'apps."
- "explicit_default_config_mismatch_app.apps."
- "ImplicitDefaultConfigMismatch'. You should move the default "
- "config class to the apps submodule of your application and, if "
- "this module defines several config classes, mark the default one "
- "with default = True."
- )
- with self.assertRaisesMessage(RemovedInDjango41Warning, msg):
- with self.settings(INSTALLED_APPS=['apps.explicit_default_config_mismatch_app']):
- pass
- with ignore_warnings(category=RemovedInDjango41Warning):
- with self.settings(INSTALLED_APPS=['apps.explicit_default_config_mismatch_app']):
- self.assertIsInstance(
- apps.get_app_config('explicit_default_config_mismatch_app'),
- ExplicitDefaultConfigMismatch,
- )
-
- def test_explicit_default_app_config_empty_apps(self):
- """
- Load an app that specifies a default AppConfig class in __init__ and
- have an empty apps module.
- """
- msg = (
- "'apps.explicit_default_config_empty_apps' defines "
- "default_app_config = 'apps.explicit_default_config_empty_apps."
- "ExplicitDefaultConfigEmptyApps'. However, Django's automatic "
- "detection did not find this configuration. You should move the "
- "default config class to the apps submodule of your application "
- "and, if this module defines several config classes, mark the "
- "default one with default = True."
- )
- with self.assertRaisesMessage(RemovedInDjango41Warning, msg):
- with self.settings(INSTALLED_APPS=['apps.explicit_default_config_empty_apps']):
- pass
- with ignore_warnings(category=RemovedInDjango41Warning):
- with self.settings(INSTALLED_APPS=['apps.explicit_default_config_empty_apps']):
- self.assertIsInstance(
- apps.get_app_config('explicit_default_config_empty_apps'),
- ExplicitDefaultConfigEmptyApps,
- )
-
- def test_explicit_default_app_config_without_apps(self):
- """
- Load an app that specifies a default AppConfig class in __init__ and do
- not have an apps module.
- """
- msg = (
- "'apps.explicit_default_config_without_apps' defines "
- "default_app_config = 'apps.explicit_default_config_without_apps."
- "ExplicitDefaultConfigWithoutApps'. However, Django's automatic "
- "detection did not find this configuration. You should move the "
- "default config class to the apps submodule of your application "
- "and, if this module defines several config classes, mark the "
- "default one with default = True."
- )
- with self.assertRaisesMessage(RemovedInDjango41Warning, msg):
- with self.settings(INSTALLED_APPS=['apps.explicit_default_config_without_apps']):
- pass
- with ignore_warnings(category=RemovedInDjango41Warning):
- with self.settings(INSTALLED_APPS=['apps.explicit_default_config_without_apps']):
- self.assertIsInstance(
- apps.get_app_config('explicit_default_config_without_apps'),
- ExplicitDefaultConfigWithoutApps,
- )