Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #16593 -- Refactored proxy_model_inheritance fixture setup to m…

…inimize the chances of leaving a modified INSTALLED_APPS setting for tests ran after it if setUp fails. Thanks Jim Dalton for the report and patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16593 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit e9a909e30ab63cc4faa28e4d9296f522bbe3bb06 1 parent 27eb8bb
Ramiro Morales authored August 10, 2011
15  tests/modeltests/proxy_model_inheritance/tests.py
@@ -13,24 +13,25 @@
13 13
 from django.core.management import call_command
14 14
 from django.db.models.loading import load_app
15 15
 from django.test import TransactionTestCase
  16
+from django.test.utils import override_settings
16 17
 
  18
+# @override_settings(INSTALLED_APPS=('app1', 'app2'))
17 19
 class ProxyModelInheritanceTests(TransactionTestCase):
18 20
 
19 21
     def setUp(self):
20 22
         self.old_sys_path = sys.path[:]
21 23
         sys.path.append(os.path.dirname(os.path.abspath(__file__)))
22  
-        self.old_installed_apps = settings.INSTALLED_APPS
23  
-        settings.INSTALLED_APPS = ('app1', 'app2')
24 24
         map(load_app, settings.INSTALLED_APPS)
25  
-        call_command('syncdb', verbosity=0)
26  
-        global ProxyModel, NiceModel
27  
-        from app1.models import ProxyModel
28  
-        from app2.models import NiceModel
29 25
 
30 26
     def tearDown(self):
31  
-        settings.INSTALLED_APPS = self.old_installed_apps
32 27
         sys.path = self.old_sys_path
33 28
 
34 29
     def test_table_exists(self):
  30
+        call_command('syncdb', verbosity=0)
  31
+        global ProxyModel, NiceModel
  32
+        from app1.models import ProxyModel
  33
+        from app2.models import NiceModel
35 34
         self.assertEqual(NiceModel.objects.all().count(), 0)
36 35
         self.assertEqual(ProxyModel.objects.all().count(), 0)
  36
+
  37
+ProxyModelInheritanceTests = override_settings(INSTALLED_APPS=('app1', 'app2'))(ProxyModelInheritanceTests)

0 notes on commit e9a909e

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