Ticket #13389: 13389.diff

File 13389.diff, 2.9 KB (added by Ramiro Morales, 15 years ago)
  • tests/regressiontests/app_loading/tests.py

    diff -r 4e50391161c1 tests/regressiontests/app_loading/tests.py
    a b  
    44from unittest import TestCase
    55
    66from django.conf import Settings
    7 from django.db.models.loading import load_app
     7import django.db.models.loading
    88
    99__test__ = {"API_TESTS": """
    1010Test the globbing of INSTALLED_APPS.
     
    3232    def setUp(self):
    3333        self.old_path = sys.path
    3434        self.egg_dir = '%s/eggs' % os.path.dirname(__file__)
     35        self.models_module = None
    3536
    3637    def tearDown(self):
    3738        sys.path = self.old_path
     39        if self.models_module is not None:
     40            del django.db.models.loading.cache.app_store[self.models_module]
     41
    3842
    3943    def test_egg1(self):
    4044        """Models module can be loaded from an app in an egg"""
    4145        egg_name = '%s/modelapp.egg' % self.egg_dir
    4246        sys.path.append(egg_name)
    43         models = load_app('app_with_models')
     47        models = django.db.models.loading.load_app('app_with_models')
    4448        self.failIf(models is None)
     49        self.models_module = models
    4550
    4651    def test_egg2(self):
    4752        """Loading an app from an egg that has no models returns no models (and no error)"""
    4853        egg_name = '%s/nomodelapp.egg' % self.egg_dir
    4954        sys.path.append(egg_name)
    50         models = load_app('app_no_models')
     55        models = django.db.models.loading.load_app('app_no_models')
    5156        self.failUnless(models is None)
    5257
    5358    def test_egg3(self):
    5459        """Models module can be loaded from an app located under an egg's top-level package"""
    5560        egg_name = '%s/omelet.egg' % self.egg_dir
    5661        sys.path.append(egg_name)
    57         models = load_app('omelet.app_with_models')
     62        models = django.db.models.loading.load_app('omelet.app_with_models')
    5863        self.failIf(models is None)
     64        self.models_module = models
    5965
    6066    def test_egg4(self):
    6167        """Loading an app with no models from under the top-level egg package generates no error"""
    6268        egg_name = '%s/omelet.egg' % self.egg_dir
    6369        sys.path.append(egg_name)
    64         models = load_app('omelet.app_no_models')
     70        models = django.db.models.loading.load_app('omelet.app_no_models')
    6571        self.failUnless(models is None)
    6672 
    6773    def test_egg5(self):
    6874        """Loading an app from an egg that has an import error in its models module raises that error"""
    6975        egg_name = '%s/brokenapp.egg' % self.egg_dir
    7076        sys.path.append(egg_name)
    71         self.assertRaises(ImportError, load_app, 'broken_app')
     77        self.assertRaises(ImportError, django.db.models.loading.load_app, 'broken_app')
    7278        try:
    73             load_app('broken_app')
     79            django.db.models.loading.load_app('broken_app')
    7480        except ImportError, e:
    7581            # Make sure the message is indicating the actual
    7682            # problem in the broken app.
Back to Top