1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Use assertIsInstance in tests.

Gives much nicer errors when it fails.
This commit is contained in:
Marc Tamlyn
2013-05-21 10:42:15 +01:00
parent 18856f866c
commit 09f8652765
31 changed files with 87 additions and 87 deletions

View File

@@ -510,13 +510,13 @@ class BaseCacheTests(object):
# memcached does not allow whitespace or control characters in keys
self.cache.set('key with spaces', 'value')
self.assertEqual(len(w), 2)
self.assertTrue(isinstance(w[0].message, CacheKeyWarning))
self.assertIsInstance(w[0].message, CacheKeyWarning)
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
# memcached limits key length to 250
self.cache.set('a' * 251, 'value')
self.assertEqual(len(w), 1)
self.assertTrue(isinstance(w[0].message, CacheKeyWarning))
self.assertIsInstance(w[0].message, CacheKeyWarning)
finally:
self.cache.key_func = old_func
@@ -1097,10 +1097,10 @@ class GetCacheTests(unittest.TestCase):
def test_simple(self):
cache = get_cache('locmem://')
from django.core.cache.backends.locmem import LocMemCache
self.assertTrue(isinstance(cache, LocMemCache))
self.assertIsInstance(cache, LocMemCache)
from django.core.cache import cache
self.assertTrue(isinstance(cache, get_cache('default').__class__))
self.assertIsInstance(cache, get_cache('default').__class__)
cache = get_cache(
'django.core.cache.backends.dummy.DummyCache', **{'TIMEOUT': 120})