summaryrefslogtreecommitdiff
path: root/tests/app_loading/tests.py
AgeCommit message (Collapse)Author
2023-12-31Used addCleanup() in tests where appropriate.Mariusz Felisiak
2022-02-07Refs #33476 -- Refactored code to strictly match 88 characters line length.Mariusz Felisiak
2022-02-07Refs #33476 -- Reformatted code with Black.django-bot
2017-01-20Refs #23919 -- Removed django.utils._os.upath()/npath()/abspathu() usage.Tim Graham
These functions do nothing on Python 3.
2017-01-18Refs #23919 -- Removed encoding preambles and future importsClaude Paroz
2016-01-29Refs #26022 -- Replaced six.assertRaisesRegex with assertRaisesMessage as ↵Hasan
appropriate.
2015-05-20Refs #24652 -- Used SimpleTestCase where appropriate.Simon Charette
2015-02-06Sorted imports with isort; refs #23860.Tim Graham
2014-01-25Moved sys.path-extending decorator to django.test.utils and used throughout ↵Carl Meyer
test suite. Thanks Aymeric for the suggestion.
2014-01-05Fixed app registry cleanup in app-loading tests.Aymeric Augustin
2013-12-29Deprecated the app argument of apps.get_models.Aymeric Augustin
Use app_config.get_models() instead.
2013-12-29Used Apps.clear_cache() in tests that alter the app registry.Aymeric Augustin
2013-12-28Removed the only_installed argument of Apps.get_models.Aymeric Augustin
Refs #15903, #15866, #15850.
2013-12-28Changed get_model to raise an exception on errors.Aymeric Augustin
Returning None on errors required unpythonic error checking and was inconsistent with get_app_config. get_model was a private API until the previous commit, but given that it was certainly used in third party software, the change is explained in the release notes. Applied the same change to get_registered_model, which is a new private API introduced during the recent refactoring.
2013-12-28Stopped calling apps.get_model with only_installed=False.Aymeric Augustin
ContentTypes are only created for installed applications, and I could make a case for not returning a model that isn't installed any more. The check for stale ContentTypes in update_contenttypes doesn't use model_class. ModelSignal actually needs get_registered_model since the lookup happens at import time. I took this opportunity to perform a small refactoring.
2013-12-24Renamed AppCache to Apps.Aymeric Augustin
Also renamed app_cache to apps and "app cache" to "app registry". Deprecated AppCache.app_cache_ready() in favor of Apps.ready().
2013-12-24Replaced ad-hoc caching of get_models with lru_cache.Aymeric Augustin
Invalidate properly the cache whenever all_models or app_configs change. This fixes some isolation issues in the test suite.
2013-12-23Dropped AppCache._empty, _with_app and _without_app.Aymeric Augustin
It's now easier to achieve the same effect with modify_settings or override_settings.
2013-12-23Refactored INSTALLED_APPS overrides.Aymeric Augustin
* Introduced [un]set_installed_apps to handle changes to the INSTALLED_APPS setting. * Refactored [un]set_available_apps to share its implementation with [un]set_installed_apps. * Implemented a receiver to clear some app-related caches. * Removed test_missing_app as it is basically impossible to reproduce this situation with public methods of the new app cache.
2013-12-22Moved apps back in the toplevel django namespace.Aymeric Augustin
Reverted 4a56a93cc458e9ab4dcab95d9f5067d4975dd1a2.
2013-12-22Complained on override_settings(INSTALLED_APPS=...).Aymeric Augustin
Currently such overrides aren't reflected in the app cache. It would be possible to handle them. But that doesn't look like a very good API. It makes it complicated to express "add this app" and "remove this app", which are the most common operations on INSTALLED_APPS.
2013-12-22Deprecated load_app().Aymeric Augustin
Adjusted several tests that used it to add apps to the app cache and then attempted to remove them by manipulating attributes directly. Also renamed invalid_models to invalid_models_tests to avoid clashing application labels between the outer and the inner invalid_models applications.
2013-12-22Terminated AppCache._populate() with extreme prejudice.Aymeric Augustin
It was called _populate() before I renamed it to populate(). Since it has been superseded by populate_models() there's no reason to keep it. Removed the can_postpone argument of load_app() as it was only used by populate(). It's a private API and there's no replacement. Simplified load_app() accordingly. Then new version behaves exactly like the old one even though it's much shorter.
2013-12-22Refactored registration of models.Aymeric Augustin
Got rid of AppConfig._stub. As a side effect, app_cache.app_configs now only contains entries for applications that are in INSTALLED_APPS, which is a good thing and will allow dramatic simplifications (which I will perform in the next commit). That required adjusting all methods that iterate on app_configs without checking the "installed" flag, hence the large changes in get_model[s]. Introduced AppCache.all_models to store models: - while the app cache is being populated and a suitable app config object to register models isn't available yet; - for applications that aren't in INSTALLED_APPS since they don't have an app config any longer. Replaced get_model(seed_cache=False) by registered_model() which can be kept simple and safe to call at any time, and removed the seed_cache argument to get_model[s]. There's no replacement for that private API. Allowed non-master app caches to go through populate() as it is now safe to do so. They were introduced in 1.7 so backwards compatibility isn't a concern as long as the migrations framework keeps working.
2013-12-17Deborgified the app cache.Aymeric Augustin
Improved Andrew's hack to create temporary app caches to handle migrations. Now the main app cache has a "master" flag set to True (which is a non-default keyword argument, thus unlikely to be used by mistake). Other app cache instances have "master" set to False. The only sanctioned way to access the app cache is by importing django.core.apps.app_cache. If you were instanciating an app cache and relying on the Borg pattern, you'll have to refactor your code.
2013-12-17Moved the new app cache inside core.Aymeric Augustin
2013-12-17Moved list of models inside AppConfig instances.Aymeric Augustin
This commit is a refactoring with no change of functionality, according to the following invariants: - An app_label that was in app_configs and app_models stays in app_config and has its 'installed' attribute set to True. - An app_label that was in app_models but not in app_configs is added to app_configs and has its 'installed' attribute set to True. As a consequence, all the code that iterated on app_configs is modified to check for the 'installed' attribute. Code that iterated on app_models is rewritten in terms of app_configs. Many tests that stored and restored the state of the app cache were updated. In the long term, we should reconsider the usefulness of allowing importing models from non-installed applications. This doesn't sound particularly useful, can be a trap in some circumstances, and causes significant complexity in sensitive areas of Django.
2013-12-17Removed module-level functions for the app cache.Aymeric Augustin
Since the original ones in django.db.models.loading were kept only for backwards compatibility, there's no need to recreate them. However, many internals of Django still relied on them. They were also imported in django.db.models. They never appear in the documentation, except a quick mention of get_models and get_app in the 1.2 release notes to document an edge case in GIS. I don't think that makes them a public API. This commit doesn't change the overall amount of global state but clarifies that it's tied to the app_cache object instead of hiding it behind half a dozen functions.
2013-12-17Removed BaseAppCache.app_store.Aymeric Augustin
It was only storing redundant information. This is part of the effort to allow applications without a models module.
2013-12-17Moved django.db.models.loading to django.apps.cache.Aymeric Augustin
This commit doesn't contain any code changes; it's purely a refactoring.
2013-11-02Fixed #21302 -- Fixed unused imports and import *.Tim Graham
2013-10-18Fixed #21268 -- Fixed E303 pep8 warningsAlasdair Nicol
2013-08-05Fixed #17667 -- Prevented app loading from skipping nonexistent apps after ↵Tim Graham
the first try Thanks ea2100@ for the report and akaariai for the patch.
2013-07-29Removed most of absolute_import importsClaude Paroz
Should be unneeded with Python 2.7 and up. Added some unicode_literals along the way.
2013-07-01Stopped using django.utils.unittest in the test suite.Aymeric Augustin
Refs #20680.
2013-02-26Merged regressiontests and modeltests into the test root.Florian Apolloner