def test_recent_items_queue_remove(): ris = RecentItemStack(4) ris.push(1) ris.push(2) eq_(list(ris), [1, 2]) ris.discard(1) eq_(list(ris), [2])
def test_recent_items_queue_reset(): items = list(range(10)) ris = RecentItemStack(4) ris.reset(items) eq_(len(ris), 4) eq_(list(ris), items[-4:]) ris.reset() eq_(len(ris), 0)
def test_recent_items_queue_update_and_pop(): ris = RecentItemStack(4) items = [8, 2, 6, 4, 5, 7] for item in items: ris.push(item) eq_(len(ris), 4) for item in reversed(items[-4:]): eq_(ris.pop(), item) eq_(len(ris), 0)
def test_recent_items_queue_push_existing(): ris = RecentItemStack(4) ris.push(1) ris.push(2) ris.push(3) eq_(list(ris), [1, 2, 3]) ris.push(1) eq_(list(ris), [2, 3, 1]) ris.push(3) eq_(list(ris), [2, 1, 3])
def test_recent_items_pop_empty(): ris = RecentItemStack(4) eq_(len(ris), 0) assert ris.pop() is None
def test_recent_items_size_zero(): ris = RecentItemStack(0) eq_(list(ris), []) ris.push(1) eq_(list(ris), []) eq_(ris.pop(), None)