Node A Node is going to be the most basic element of our collections, it represents a single element in the collection. A node has two parameters on instantiation:
value
: This contains the value at this elementnext
(optional): The next element in the collection after this element. If nonext
is provided, it should be set toNone
Sequenceable Sequenceable collections are well... sequenceable. They have both a
start
and anend
and you can process all the items in between in sequence. They also provide aget_elements()
method to retrieve all the elements of the collection.start
: This should be the firstNode
in the sequence and should be intialised toNone
end
: This should be the lastNode
in the sequence and should be initialised toNone
get_elements()
: returns a list containing all the values of theNode
s in the collection in order.
Appendable Collections that are appendable provide the
append(element)
method which adds aNode
with avalue
ofelement
to the end of the sequence. This method should update thestart
andend
if necessary.
Popable Popable collections provide the
pop()
method which removes the first element from a sequence and returns itsvalue
. This method must also updatestart
/end
as necessary.
Pushable Pushable collections provide the
push(element)
method which adds aNode
to the beginning of the sequence with avalue
ofelement
, updatingstart
/end
when necessary.
# Default. Verbose if too many tests failing
$ py.test tests.py
List tests with -v
$ py.test -v tests.py
Control traceback with --tb
$ py.test -v --tb=short tests.py
Match test by name with the -k argument
$ py.test -v --tb=short tests.py -k test_sequenceable
Run an individual test with a "hard" reference
py.test -v --tb=short tests.py::test_sequenceable
Just run $ tox
to run your tests for every version defined in tox.ini
.
Run for a single python version with -e
(General syntax: tox -e[PYTHON-VERSION]
). Example:
$ tox -epy27