summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_functools.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2011-10-16 07:00:51 (GMT)
committerRaymond Hettinger <python@rcn.com>2011-10-16 07:00:51 (GMT)
commitd8886fc831e16ab225f7e474751cc1a7b3cd01df (patch)
treebd216e577165057f7a0db675886c335e5892a80b /Lib/test/test_functools.py
parente60698317dc7772983784037d966d24d1d30dc87 (diff)
parent4b779b3785c0014224eef95c8805f166d0ef2a86 (diff)
downloadcpython-d8886fc831e16ab225f7e474751cc1a7b3cd01df.zip
cpython-d8886fc831e16ab225f7e474751cc1a7b3cd01df.tar.gz
cpython-d8886fc831e16ab225f7e474751cc1a7b3cd01df.tar.bz2
Merge
Diffstat (limited to 'Lib/test/test_functools.py')
-rw-r--r--Lib/test/test_functools.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py
index 97d7524..a31c92e 100644
--- a/Lib/test/test_functools.py
+++ b/Lib/test/test_functools.py
@@ -718,6 +718,22 @@ class TestLRU(unittest.TestCase):
self.assertEqual(fib.cache_info(),
functools._CacheInfo(hits=0, misses=0, maxsize=None, currsize=0))
+ def test_lru_with_exceptions(self):
+ # Verify that user_function exceptions get passed through without
+ # creating a hard-to-read chained exception.
+ # http://bugs.python.org/issue13177
+ for maxsize in (None, 100):
+ @functools.lru_cache(maxsize)
+ def func(i):
+ return 'abc'[i]
+ self.assertEqual(func(0), 'a')
+ with self.assertRaises(IndexError) as cm:
+ func(15)
+ self.assertIsNone(cm.exception.__context__)
+ # Verify that the previous exception did not result in a cached entry
+ with self.assertRaises(IndexError):
+ func(15)
+
def test_main(verbose=None):
test_classes = (
TestPartial,