summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_functools.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2010-11-30 19:15:45 (GMT)
committerRaymond Hettinger <python@rcn.com>2010-11-30 19:15:45 (GMT)
commit7496b4171e6a34a82ba388fa0ef125d8b87aa2a1 (patch)
treeed8fc1ddcee597b3273caf464d2397c51bd66be4 /Lib/test/test_functools.py
parentd01df46848da8c500665cfd59b84a1ebf25f25a2 (diff)
downloadcpython-7496b4171e6a34a82ba388fa0ef125d8b87aa2a1.zip
cpython-7496b4171e6a34a82ba388fa0ef125d8b87aa2a1.tar.gz
cpython-7496b4171e6a34a82ba388fa0ef125d8b87aa2a1.tar.bz2
Add example, tighten text, and minor clean-ups.
Diffstat (limited to 'Lib/test/test_functools.py')
-rw-r--r--Lib/test/test_functools.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py
index c877f88..8f48e9e 100644
--- a/Lib/test/test_functools.py
+++ b/Lib/test/test_functools.py
@@ -501,7 +501,7 @@ class TestLRU(unittest.TestCase):
def orig(x, y):
return 3*x+y
f = functools.lru_cache(maxsize=20)(orig)
- maxsize, currsize, hits, misses = f.cache_info()
+ hits, misses, maxsize, currsize = f.cache_info()
self.assertEqual(maxsize, 20)
self.assertEqual(currsize, 0)
self.assertEqual(hits, 0)
@@ -513,18 +513,18 @@ class TestLRU(unittest.TestCase):
actual = f(x, y)
expected = orig(x, y)
self.assertEqual(actual, expected)
- maxsize, currsize, hits, misses = f.cache_info()
+ hits, misses, maxsize, currsize = f.cache_info()
self.assertTrue(hits > misses)
self.assertEqual(hits + misses, 1000)
self.assertEqual(currsize, 20)
f.cache_clear() # test clearing
- maxsize, currsize, hits, misses = f.cache_info()
+ hits, misses, maxsize, currsize = f.cache_info()
self.assertEqual(hits, 0)
self.assertEqual(misses, 0)
self.assertEqual(currsize, 0)
f(x, y)
- maxsize, currsize, hits, misses = f.cache_info()
+ hits, misses, maxsize, currsize = f.cache_info()
self.assertEqual(hits, 0)
self.assertEqual(misses, 1)
self.assertEqual(currsize, 1)
@@ -532,7 +532,7 @@ class TestLRU(unittest.TestCase):
# Test bypassing the cache
self.assertIs(f.__wrapped__, orig)
f.__wrapped__(x, y)
- maxsize, currsize, hits, misses = f.cache_info()
+ hits, misses, maxsize, currsize = f.cache_info()
self.assertEqual(hits, 0)
self.assertEqual(misses, 1)
self.assertEqual(currsize, 1)
@@ -548,7 +548,7 @@ class TestLRU(unittest.TestCase):
for i in range(5):
self.assertEqual(f(), 20)
self.assertEqual(f_cnt, 5)
- maxsize, currsize, hits, misses = f.cache_info()
+ hits, misses, maxsize, currsize = f.cache_info()
self.assertEqual(hits, 0)
self.assertEqual(misses, 5)
self.assertEqual(currsize, 0)
@@ -564,7 +564,7 @@ class TestLRU(unittest.TestCase):
for i in range(5):
self.assertEqual(f(), 20)
self.assertEqual(f_cnt, 1)
- maxsize, currsize, hits, misses = f.cache_info()
+ hits, misses, maxsize, currsize = f.cache_info()
self.assertEqual(hits, 4)
self.assertEqual(misses, 1)
self.assertEqual(currsize, 1)
@@ -581,7 +581,7 @@ class TestLRU(unittest.TestCase):
# * * * *
self.assertEqual(f(x), x*10)
self.assertEqual(f_cnt, 4)
- maxsize, currsize, hits, misses = f.cache_info()
+ hits, misses, maxsize, currsize = f.cache_info()
self.assertEqual(hits, 12)
self.assertEqual(misses, 4)
self.assertEqual(currsize, 2)