From 68f0e8d8b1f9bdf9fc1c26ca5ec62a88c691ca20 Mon Sep 17 00:00:00 2001 From: caleb logan Date: Wed, 30 Aug 2017 21:22:26 -0700 Subject: Fixed #28500 -- Fixed crash in FileBasedCache._is_expired() if the cache file is empty. --- tests/cache/tests.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests/cache') diff --git a/tests/cache/tests.py b/tests/cache/tests.py index eb5865f08d..cef000cb02 100644 --- a/tests/cache/tests.py +++ b/tests/cache/tests.py @@ -1366,6 +1366,13 @@ class FileBasedCacheTests(BaseCacheTests, TestCase): with self.assertRaises(IOError): cache.get('foo') + def test_empty_cache_file_considered_expired(self): + cache_file = cache._key_to_file('foo') + with open(cache_file, 'wb') as fh: + fh.write(b'') + with open(cache_file, 'rb') as fh: + self.assertIs(cache._is_expired(fh), True) + @override_settings(CACHES={ 'default': { -- cgit v1.3