diff options
Diffstat (limited to 'Lib/test/test_functools.py')
-rw-r--r-- | Lib/test/test_functools.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py index 7bc355f..08cf457 100644 --- a/Lib/test/test_functools.py +++ b/Lib/test/test_functools.py @@ -1495,6 +1495,33 @@ class TestLRU: self.assertEqual(square.cache_info().hits, 4) self.assertEqual(square.cache_info().misses, 4) + def test_lru_cache_typed_is_not_recursive(self): + cached = self.module.lru_cache(typed=True)(repr) + + self.assertEqual(cached(1), '1') + self.assertEqual(cached(True), 'True') + self.assertEqual(cached(1.0), '1.0') + self.assertEqual(cached(0), '0') + self.assertEqual(cached(False), 'False') + self.assertEqual(cached(0.0), '0.0') + + self.assertEqual(cached((1,)), '(1,)') + self.assertEqual(cached((True,)), '(1,)') + self.assertEqual(cached((1.0,)), '(1,)') + self.assertEqual(cached((0,)), '(0,)') + self.assertEqual(cached((False,)), '(0,)') + self.assertEqual(cached((0.0,)), '(0,)') + + class T(tuple): + pass + + self.assertEqual(cached(T((1,))), '(1,)') + self.assertEqual(cached(T((True,))), '(1,)') + self.assertEqual(cached(T((1.0,))), '(1,)') + self.assertEqual(cached(T((0,))), '(0,)') + self.assertEqual(cached(T((False,))), '(0,)') + self.assertEqual(cached(T((0.0,))), '(0,)') + def test_lru_with_keyword_args(self): @self.module.lru_cache() def fib(n): |