Author: jezdez
Date: 2011-07-05 02:40:29 -0700 (Tue, 05 Jul 2011)
New Revision: 16512

Modified:
   django/trunk/tests/regressiontests/cache/tests.py
Log:
Fixed test failure on Postgres that was added in r16510.

Modified: django/trunk/tests/regressiontests/cache/tests.py
===================================================================
--- django/trunk/tests/regressiontests/cache/tests.py   2011-07-05 09:10:58 UTC 
(rev 16511)
+++ django/trunk/tests/regressiontests/cache/tests.py   2011-07-05 09:40:29 UTC 
(rev 16512)
@@ -2,6 +2,7 @@
 
 # Unit tests for cache framework
 # Uses whatever cache backend is set in the test settings file.
+from __future__ import with_statement
 
 import hashlib
 import os
@@ -775,23 +776,23 @@
 
 class CreateCacheTableForDBCacheTests(unittest.TestCase):
 
-    @override_settings(DEBUG=True)
     def test_createcachetable_observes_database_router(self):
-        old_routers = router.routers
-        try:
-            router.routers = [DBCacheRouter()]
-            # cache table should not be created on 'default'
-            management.call_command('createcachetable', 'cache_table',
-                                    database='default',
-                                    verbosity=0, interactive=False)
-            self.assertEqual(len(connections['default'].queries), 0)
-            # cache table should be created on 'other'
-            management.call_command('createcachetable', 'cache_table',
-                                    database='other',
-                                    verbosity=0, interactive=False)
-            self.assertNotEqual(len(connections['other'].queries), 0)
-        finally:
-            router.routers = old_routers
+        with override_settings(DEBUG=True):
+            old_routers = router.routers
+            try:
+                router.routers = [DBCacheRouter()]
+                # cache table should not be created on 'default'
+                management.call_command('createcachetable', 'cache_table',
+                                        database='default',
+                                        verbosity=0, interactive=False)
+                self.assertEqual(len(connections['default'].queries), 0)
+                # cache table should be created on 'other'
+                management.call_command('createcachetable', 'cache_table',
+                                        database='other',
+                                        verbosity=0, interactive=False)
+                self.assertNotEqual(len(connections['other'].queries), 0)
+            finally:
+                router.routers = old_routers
 
 class LocMemCacheTests(unittest.TestCase, BaseCacheTests):
     backend_name = 'django.core.cache.backends.locmem.LocMemCache'

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to