Skip to content

Commit b276095

Browse files
committed
Update readme and tests
1 parent 523d3fd commit b276095

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

README.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ This can be used to build a LRU cache. Usage is almost like a dict.
4545
# Would print [(3, '3'), (5, '5'), (2, '2'), (1, '1')]
4646
4747
print l.get_size()
48-
#Would print 5
48+
# Would print 5
49+
4950
l.set_size(3)
5051
print l.items()
5152
# Would print [(3, '3'), (5, '5'), (2, '2')]
@@ -59,9 +60,14 @@ This can be used to build a LRU cache. Usage is almost like a dict.
5960
l.get_stats()
6061
# Would print (1, 0)
6162
63+
64+
l.update(5='0') # Update an item
65+
print l.items()
66+
# Would print [(5, '0'), (3, '3'), (2, '2')]
67+
6268
l.clear()
6369
print l.items()
64-
#Would print []
70+
# Would print []
6571
6672
Install
6773
=======

test/test_lru.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,17 @@ def test_update(self):
116116
l['b'] = 2
117117
self.assertEqual(l['b'], 2)
118118
l.update(b=3)
119+
self.assertEqual(('b', 3), l.peek_first_item())
119120
self.assertEqual(l['a'], 2)
120121
self.assertEqual(l['b'], 3)
121122
l.update({'a':1, 'b':2})
123+
self.assertEqual(('b', 2), l.peek_first_item())
122124
self.assertEqual(l['a'], 1)
123125
self.assertEqual(l['b'], 2)
124126
l.update()
127+
self.assertEqual(('b', 2), l.peek_first_item())
128+
l.update(a=2)
129+
self.assertEqual(('a', 2), l.peek_first_item())
125130

126131

127132
def test_peek_first_item(self):

0 commit comments

Comments
 (0)