Skip to content

justenh/pyp-u1-c1-collections-hierarchy

 
 

Repository files navigation

Collections Hierarchy

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 element next (optional): The next element in the collection after this element. If no next is provided, it should be set to None

Base Classes

Sequenceable Sequenceable collections are well... sequenceable. They have both a start and an end and you can process all the items in between in sequence. They also provide a get_elements() method to retrieve all the elements of the collection. start: This should be the first Node in the sequence and should be intialised to None end: This should be the last Node in the sequence and should be initialised to None get_elements(): returns a list containing all the values of the Nodes in the collection in order.


Appendable Collections that are appendable provide the append(element) method which adds a Node with a value of element to the end of the sequence. This method should update the start and end if necessary.


Popable Popable collections provide the pop() method which removes the first element from a sequence and returns its value. This method must also update start/end as necessary.


Pushable Pushable collections provide the push(element) method which adds a Node to the beginning of the sequence with a value of element, updating start/end when necessary.

Running Tests

# Default. Verbose if too many tests failing
$ py.test tests.py

List tests with -v

image

$ py.test -v tests.py

Control traceback with --tb

image

$ py.test -v --tb=short tests.py

Match test by name with the -k argument

image

$ py.test -v --tb=short tests.py -k test_sequenceable

Run an individual test with a "hard" reference

image

py.test -v --tb=short tests.py::test_sequenceable

Running tests with different Python Versions using Tox

Just run $ tox to run your tests for every version defined in tox.ini.

Run for a single python version with -e

image

(General syntax: tox -e[PYTHON-VERSION]). Example:

$ tox -epy27

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%