summaryrefslogtreecommitdiff
path: root/tests/app_loading
Commit message (Collapse)AuthorAgeFilesLines
* Refs #33476 -- Refactored code to strictly match 88 characters line length.Mariusz Felisiak2022-02-071-4/+16
|
* Refs #33476 -- Reformatted code with Black.django-bot2022-02-072-30/+25
|
* Refs #23919 -- Removed django.utils._os.upath()/npath()/abspathu() usage.Tim Graham2017-01-201-2/+1
| | | These functions do nothing on Python 3.
* Refs #23919 -- Removed encoding preambles and future importsClaude Paroz2017-01-181-2/+0
|
* Refs #26022 -- Replaced six.assertRaisesRegex with assertRaisesMessage as ↵Hasan2016-01-291-2/+1
| | | | appropriate.
* Fixed #21127 -- Started deprecation toward requiring on_delete for ↵Flavio Curella2015-07-271-1/+1
| | | | ForeignKey/OneToOneField
* Refs #24652 -- Used SimpleTestCase where appropriate.Simon Charette2015-05-201-3/+3
|
* Sorted imports with isort; refs #23860.Tim Graham2015-02-061-1/+1
|
* Moved sys.path-extending decorator to django.test.utils and used throughout ↵Carl Meyer2014-01-251-23/+21
| | | | | | test suite. Thanks Aymeric for the suggestion.
* Fixed app registry cleanup in app-loading tests.Aymeric Augustin2014-01-051-6/+4
|
* Fixed test for models in non-installed apps.Aymeric Augustin2014-01-051-1/+11
| | | | | | | | | Models are now attached to any application they're defined in. Since not_installed was inside app_loading, these models were mistakenly attached to app_loading. The test that used them passed accidentally when run after EggLoadingTest because that class' tearDown() method replaces apps.all_models['app_loading'] by a copy of itself, while it should remain the same as apps.app_configs['app_loading'].models.
* Deprecated the app argument of apps.get_models.Aymeric Augustin2013-12-291-3/+0
| | | | Use app_config.get_models() instead.
* Used Apps.clear_cache() in tests that alter the app registry.Aymeric Augustin2013-12-291-1/+1
|
* Removed the only_installed argument of Apps.get_models.Aymeric Augustin2013-12-281-13/+0
| | | | Refs #15903, #15866, #15850.
* Changed get_model to raise an exception on errors.Aymeric Augustin2013-12-281-2/+2
| | | | | | | | | | | | 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.
* Stopped calling apps.get_model with only_installed=False.Aymeric Augustin2013-12-281-6/+0
| | | | | | | | | | 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.
* Renamed AppCache to Apps.Aymeric Augustin2013-12-241-13/+13
| | | | | | Also renamed app_cache to apps and "app cache" to "app registry". Deprecated AppCache.app_cache_ready() in favor of Apps.ready().
* Replaced ad-hoc caching of get_models with lru_cache.Aymeric Augustin2013-12-241-1/+1
| | | | | Invalidate properly the cache whenever all_models or app_configs change. This fixes some isolation issues in the test suite.
* Dropped AppCache._empty, _with_app and _without_app.Aymeric Augustin2013-12-231-9/+8
| | | | | It's now easier to achieve the same effect with modify_settings or override_settings.
* Refactored INSTALLED_APPS overrides.Aymeric Augustin2013-12-231-20/+0
| | | | | | | | | | * 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.
* Moved apps back in the toplevel django namespace.Aymeric Augustin2013-12-221-2/+2
| | | | Reverted 4a56a93cc458e9ab4dcab95d9f5067d4975dd1a2.
* Complained on override_settings(INSTALLED_APPS=...).Aymeric Augustin2013-12-221-5/+8
| | | | | | | | 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.
* Deprecated load_app().Aymeric Augustin2013-12-221-19/+16
| | | | | | | | | 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.
* Terminated AppCache._populate() with extreme prejudice.Aymeric Augustin2013-12-221-2/+3
| | | | | | | | | | 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.
* Refactored registration of models.Aymeric Augustin2013-12-221-7/+8
| | | | | | | | | | | | | | | | | | | | | | | 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.
* Deborgified the app cache.Aymeric Augustin2013-12-171-11/+8
| | | | | | | | | | | | | 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.
* Removed superfluous models.py files.Aymeric Augustin2013-12-171-0/+0
| | | | | | | Added comments in the three empty models.py files that are still needed. Adjusted the test runner to add applications corresponding to test labels to INSTALLED_APPS even when they don't have a models module.
* Moved the new app cache inside core.Aymeric Augustin2013-12-171-2/+2
|
* Moved list of models inside AppConfig instances.Aymeric Augustin2013-12-171-6/+6
| | | | | | | | | | | | | | | | | | | | | | | 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.
* Removed module-level functions for the app cache.Aymeric Augustin2013-12-171-16/+17
| | | | | | | | | | | | | | | 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.
* Removed BaseAppCache.app_store.Aymeric Augustin2013-12-171-2/+0
| | | | | It was only storing redundant information. This is part of the effort to allow applications without a models module.
* Moved django.db.models.loading to django.apps.cache.Aymeric Augustin2013-12-171-1/+1
| | | | This commit doesn't contain any code changes; it's purely a refactoring.
* Fixed #21302 -- Fixed unused imports and import *.Tim Graham2013-11-021-2/+0
|
* Fixed #21268 -- Fixed E303 pep8 warningsAlasdair Nicol2013-10-181-5/+0
|
* Fixed #17667 -- Prevented app loading from skipping nonexistent apps after ↵Tim Graham2013-08-051-4/+26
| | | | | | the first try Thanks ea2100@ for the report and akaariai for the patch.
* Removed most of absolute_import importsClaude Paroz2013-07-291-1/+1
| | | | | Should be unneeded with Python 2.7 and up. Added some unicode_literals along the way.
* Stopped using django.utils.unittest in the test suite.Aymeric Augustin2013-07-011-1/+2
| | | | Refs #20680.
* Merged regressiontests and modeltests into the test root.Florian Apolloner2013-02-269-0/+123