diff options
| author | Jon Dufresne <jon.dufresne@gmail.com> | 2016-06-01 12:29:24 -0700 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-06-01 15:29:24 -0400 |
| commit | 779829662d48a54ac427574e5e0c279b69519e42 (patch) | |
| tree | 1894cfcf1127a4f22b58a51e75fa3c999ff5e852 /tests/cache | |
| parent | 3db04d4422326006519410715529f013faecad68 (diff) | |
Fixed #26694 -- Made FileBasedCache.get() reraise non-ENOENT IOErrors.
Diffstat (limited to 'tests/cache')
| -rw-r--r-- | tests/cache/tests.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/cache/tests.py b/tests/cache/tests.py index 1e74df1e56..e2044bbdad 100644 --- a/tests/cache/tests.py +++ b/tests/cache/tests.py @@ -5,6 +5,7 @@ from __future__ import unicode_literals import copy +import io import os import re import shutil @@ -1261,6 +1262,17 @@ class FileBasedCacheTests(BaseCacheTests, TestCase): # This fails if not using the highest pickling protocol on Python 2. cache.set('unpicklable', UnpicklableType()) + def test_get_ignores_enoent(self): + cache.set('foo', 'bar') + os.unlink(cache._key_to_file('foo')) + # Returns the default instead of erroring. + self.assertEqual(cache.get('foo', 'baz'), 'baz') + + def test_get_does_not_ignore_non_enoent_errno_values(self): + with mock.patch.object(io, 'open', side_effect=IOError): + with self.assertRaises(IOError): + cache.get('foo') + @override_settings(CACHES={ 'default': { |
