mirror of
https://github.com/django/django.git
synced 2025-09-26 12:09:19 +00:00
Fixed #15866, #15850 -- Prevented get_model() and get_models() from returning not-installed models (by default). Thanks adsva for report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16053 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
fda8a9a390
commit
6bdaef26ec
8 changed files with 67 additions and 12 deletions
|
@ -4,7 +4,7 @@ import sys
|
|||
import time
|
||||
|
||||
from django.conf import Settings
|
||||
from django.db.models.loading import cache, load_app
|
||||
from django.db.models.loading import cache, load_app, get_model, get_models
|
||||
from django.utils.unittest import TestCase
|
||||
|
||||
|
||||
|
@ -81,3 +81,24 @@ class EggLoadingTest(TestCase):
|
|||
# Make sure the message is indicating the actual
|
||||
# problem in the broken app.
|
||||
self.assertTrue("modelz" in e.args[0])
|
||||
|
||||
|
||||
class GetModelsTest(TestCase):
|
||||
def setUp(self):
|
||||
import not_installed.models
|
||||
self.not_installed_module = not_installed.models
|
||||
|
||||
|
||||
def test_get_model_only_returns_installed_models(self):
|
||||
self.assertEqual(
|
||||
get_model("not_installed", "NotInstalledModel"), None)
|
||||
|
||||
|
||||
def test_get_models_only_returns_installed_models(self):
|
||||
self.assertFalse(
|
||||
"NotInstalledModel" in
|
||||
[m.__name__ for m in get_models()])
|
||||
|
||||
|
||||
def test_get_models_with_app_label_only_returns_installed_models(self):
|
||||
self.assertEqual(get_models(self.not_installed_module), [])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue