Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.1.X] Fixed #13389 -- Ensured that the app_loading test clears out …

…the app cache at the end of each test, so that it doesn't interact badly with flush and other introspected database commands. Thanks to Karen for the report, and Ramiro Morales for the debugging hints.

Backport of r13011 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@13012 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 0e996983d5457d56fcf9020bf87a069734985d65 1 parent 1982c8b
Russell Keith-Magee authored April 21, 2010
13  tests/regressiontests/app_loading/tests.py
... ...
@@ -1,10 +1,11 @@
  1
+import copy
1 2
 import os
2 3
 import sys
3 4
 import time
4 5
 from unittest import TestCase
5 6
 
6 7
 from django.conf import Settings
7  
-from django.db.models.loading import load_app
  8
+from django.db.models.loading import cache, load_app
8 9
 
9 10
 __test__ = {"API_TESTS": """
10 11
 Test the globbing of INSTALLED_APPS.
@@ -33,8 +34,16 @@ def setUp(self):
33 34
         self.old_path = sys.path
34 35
         self.egg_dir = '%s/eggs' % os.path.dirname(__file__)
35 36
 
  37
+        # This test adds dummy applications to the app cache. These
  38
+        # need to be removed in order to prevent bad interactions
  39
+        # with the flush operation in other tests.
  40
+        self.old_app_models = copy.deepcopy(cache.app_models)
  41
+        self.old_app_store = copy.deepcopy(cache.app_store)
  42
+
36 43
     def tearDown(self):
37 44
         sys.path = self.old_path
  45
+        cache.app_models = self.old_app_models
  46
+        cache.app_store = self.old_app_store
38 47
 
39 48
     def test_egg1(self):
40 49
         """Models module can be loaded from an app in an egg"""
@@ -63,7 +72,7 @@ def test_egg4(self):
63 72
         sys.path.append(egg_name)
64 73
         models = load_app('omelet.app_no_models')
65 74
         self.failUnless(models is None)
66  
- 
  75
+
67 76
     def test_egg5(self):
68 77
         """Loading an app from an egg that has an import error in its models module raises that error"""
69 78
         egg_name = '%s/brokenapp.egg' % self.egg_dir

0 notes on commit 0e99698

Please sign in to comment.
Something went wrong with that request. Please try again.