def test_insert(): u"""Assert .insert() adds value/node to the h of the doubly linked list.""" doubly_linked = DoublyLinked() for val in VALUES: doubly_linked.insert(val) assert doubly_linked.head.value == val assert doubly_linked.head.value == VALUES[-1]
def test_shift(): u"""Assert .shift() removes and returns the t value from the list.""" doubly_linked = DoublyLinked() for val in VALUES: doubly_linked.insert(val) for val in VALUES: assert doubly_linked.shift() == val assert doubly_linked.shift() is None
def test_remove(): u"""Assert .remove() removes the first matching value from the list.""" doubly_linked = DoublyLinked() for val in VALUES: doubly_linked.insert(val) test_vals = VALUES[:] while test_vals: val = random.choice(test_vals) doubly_linked.remove(val) test_vals.remove(val) assert doubly_linked.pop() is None assert doubly_linked.head is None assert doubly_linked.tail is None doubly_linked.insert(1) with pytest.raises(LookupError): doubly_linked.remove("test value")