11. Unit Testing Objects
Feel free to use your laptop
You are strongly encourage to work with others
When you get stuck, ask those sitting around you for help
Get used to working together in the labs
Peer teaching and peer learning has been empirically shown to be very effective
11.1. Pre Lab Exercises
Have the previous lab complete
11.2. Before Kattis
Create a
PersonclassAttribute for
first_nameAttribute for
last_nameAttribute for
email_addressThe constructor will take three parameters for specifying the values of the attributes
A method returning a string of their
full_name()— e.g.Bob SmithWrite a reasonable
__eq__method — you can decide what it means for twoPersonobjects to be equivalentWrite a reasonable
__repr__method — you can decide what the string looks likeMake instances of the class and write
asserttests to verify correctness
Create unittest classes for the
PersonclassWrite tests for each of the methods in each class
Be sure to reference the unittest topic
You may find the
Circleclass’unittests helpfulBe sure to remove the
from src.circle import Circleline
Run the tests with
unittest.main(argv=[''], verbosity=2, exit=False)Ensure all tests pass
11.3. Kattis Problems
You should be using a scrap piece of paper to work out the ideas for the following problems
The problems you are to solve are getting too complex to try to solve by just coding
Trying to solve problems by just typing away will not yield success