Skip to content

Commit 67ae4fb

Browse files
committed
Minor test corrections and cleanups.
1 parent 8e73eae commit 67ae4fb

3 files changed

Lines changed: 8 additions & 7 deletions

File tree

tests/test_classmethod.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def test_typed(self):
7575
self.assertEqual(Cached.get_typed(0), 1)
7676
self.assertEqual(len(w), 2)
7777
self.assertIs(w[0].category, DeprecationWarning)
78-
self.assertIs(w[0].category, DeprecationWarning)
78+
self.assertIs(w[1].category, DeprecationWarning)
7979

8080
with warnings.catch_warnings():
8181
warnings.simplefilter("ignore")
@@ -99,7 +99,7 @@ def test_locked(self):
9999
self.assertEqual(Cached.get_locked(0), 1)
100100
self.assertEqual(len(w), 2)
101101
self.assertIs(w[0].category, DeprecationWarning)
102-
self.assertIs(w[0].category, DeprecationWarning)
102+
self.assertIs(w[1].category, DeprecationWarning)
103103

104104
def test_condition(self):
105105
Cached.cache = LRUCache(2)
@@ -112,7 +112,7 @@ def test_condition(self):
112112
self.assertEqual(Cached.get_condition(0), 1)
113113
self.assertEqual(len(w), 2)
114114
self.assertIs(w[0].category, DeprecationWarning)
115-
self.assertIs(w[0].category, DeprecationWarning)
115+
self.assertIs(w[1].category, DeprecationWarning)
116116

117117
def test_clear(self):
118118
Cached.cache = LRUCache(2)

tests/test_keys.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_methodkey(self, key=cachetools.keys.methodkey):
3434
self.assertNotEqual(key("x", 1, 2, 3, x=0), key("x", 1, 2, 3, x=None))
3535
self.assertNotEqual(key("x", 1, 2, 3, x=0), key("x", 1, 2, 3, y=0))
3636
with self.assertRaises(TypeError):
37-
hash("x", key({}))
37+
hash(key("x", {}))
3838
# untyped keys compare equal
3939
self.assertEqual(key("x", 1, 2, 3), key("y", 1.0, 2.0, 3.0))
4040
self.assertEqual(hash(key("x", 1, 2, 3)), hash(key("y", 1.0, 2.0, 3.0)))

tests/test_tlru.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
from . import CacheTestMixin
77

88

9+
def default_ttu(_key, _value, _time):
10+
return math.inf
11+
12+
913
class Timer:
1014
def __init__(self, auto=False):
1115
self.auto = auto
@@ -21,9 +25,6 @@ def tick(self):
2125

2226

2327
class TLRUTestCache(TLRUCache):
24-
def default_ttu(_key, _value, _time):
25-
return math.inf
26-
2728
def __init__(self, maxsize, ttu=default_ttu, **kwargs):
2829
TLRUCache.__init__(self, maxsize, ttu, timer=Timer(), **kwargs)
2930

0 commit comments

Comments
 (0)