array_set.pyc
and broken_array_set.pyc
are Python byte-code versions of modules
containing completed (but not completely tested) Set classes. pyc
files are analogous to .class files in Java. They can be imported and
used like other modules, but they are not stored in a human-readable
format. (Note that Python byte-code is NOT portable between different
versions of Python. The set modules listed above will only work
with Python 2.7.)
set_tests.py
is a module that contains unit testing code for
the Set class. Right now, it only includes tests for __init__
, add
and __contains__
. Your
goal today will be to write tests for the discard
method.
set_tests.py
. Try
running the tests. Note that array_set.pyc
must be in the
same directory as set_tests.py
in order for the tests
to execute. The Set class defined in array_set.pyc
should pass all tests and you should see output like the following:
........... ---------------------------------------------------------------------- Ran 11 tests in 0.033s OK
discard
method. Write down a list of possible tests.
discard
method
defined in array_set.pyc
is correct (as far as I know).
It should pass all of your tests. The version of discard
defined in broken_array_set.pyc
is not
correct. It contains at least two serious bugs. Your goal is to write
tests that allow you to identify those bugs.
You can change which module is being tested by changing the statement
import array_set as set_moduleto
import broken_array_set as set_modulein
set_tests.py
.
There is nothing to hand in for this assignment. Make sure that you save a copy of your code. Your code should include the names of your group members so that you can acknowledge them in your PA2 submission.