Skip to content

Commit

Permalink
Fixed test failure on Postgres that was added in r16510.
Browse files Browse the repository at this point in the history
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16512 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
jezdez committed Jul 5, 2011
1 parent 90b6181 commit 2b2bec0
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions tests/regressiontests/cache/tests.py
Expand Up @@ -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
Expand Down Expand Up @@ -775,23 +776,23 @@ def allow_syncdb(self, db, model):

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'
Expand Down

0 comments on commit 2b2bec0

Please sign in to comment.