mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #21351 -- Replaced memoize with Python's lru_cache.
Replaced the custom, untested memoize with a similar decorator from Python's 3.2 stdlib. Although some minor performance degradation (see ticket), it is expected that in the long run lru_cache will outperform memoize once it is implemented in C. Thanks to EvilDMP for the report and Baptiste Mispelon for the idea of replacing memoize with lru_cache.
This commit is contained in:
committed by
Baptiste Mispelon
parent
6c5f5b9a41
commit
9b7455e918
@@ -55,7 +55,7 @@ class BaseStaticFilesTestCase(object):
|
||||
storage.staticfiles_storage._wrapped = empty
|
||||
# Clear the cached staticfile finders, so they are reinitialized every
|
||||
# run and pick up changes in settings.STATICFILES_DIRS.
|
||||
finders._finders.clear()
|
||||
finders.get_finder.cache_clear()
|
||||
|
||||
testfiles_path = os.path.join(TEST_ROOT, 'apps', 'test', 'static', 'test')
|
||||
# To make sure SVN doesn't hangs itself with the non-ASCII characters
|
||||
@@ -561,7 +561,7 @@ class TestCollectionCachedStorage(BaseCollectionTestCase,
|
||||
Test that post_processing indicates the origin of the error when it
|
||||
fails. Regression test for #18986.
|
||||
"""
|
||||
finders._finders.clear()
|
||||
finders.get_finder.cache_clear()
|
||||
err = six.StringIO()
|
||||
with self.assertRaises(Exception):
|
||||
call_command('collectstatic', interactive=False, verbosity=0, stderr=err)
|
||||
@@ -756,6 +756,15 @@ class TestMiscFinder(TestCase):
|
||||
self.assertRaises(ImproperlyConfigured,
|
||||
finders.get_finder, 'foo.bar.FooBarFinder')
|
||||
|
||||
def test_cache(self):
|
||||
finders.get_finder.cache_clear()
|
||||
for n in range(10):
|
||||
finders.get_finder(
|
||||
'django.contrib.staticfiles.finders.FileSystemFinder')
|
||||
cache_info = finders.get_finder.cache_info()
|
||||
self.assertEqual(cache_info.hits, 9)
|
||||
self.assertEqual(cache_info.currsize, 1)
|
||||
|
||||
@override_settings(STATICFILES_DIRS='a string')
|
||||
def test_non_tuple_raises_exception(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user