Practice: Strong Code#
Code Testing#
Q1 Make a class named Person
that has two instance attributes: name
and age
. Be sure that they are assigned to user-specified values.
Then, make a method called birthday()
that increments age
by 1 and returns the string “Happy Birthday!”
Then, create a unittest
test class with only one test function that does the following:
Create an instance of the
Person
classWrite the following tests, making sure that they pass:
The instance is of instance
Person
The instance’s name is equal to the name you gave it
The instance’s age is equal to the age you gave it
Call the
birthday()
function and write a test checking if the instance’s age got incremented by 1