def test_set_gender_male(self): gender = 'Male' user = User() user.gender = gender self.assertEqual(user._gender, gender) # Checks private var has been set
def test_string_representation_of_user_invalid(self): user = User() user.name = 'Ann' user.gender = 'Female' user.smoker = 'Yes' self.assertEqual( str(user), '') # Return empty string repr if we are missing some parameters
def test_string_representation_of_user(self): user = User() user.name = 'Patrick' user.date_of_birth = '10-10-1988' user.gender = 'Male' user.smoker = 'No' self.assertEqual( str(user), 'Patrick was born on 10-10-1988 and is a Male non-smoker')
def test_get_gender(self): gender = 'Male' user = User() user.gender = gender self.assertEqual(user.gender, gender) # Checks getter is set
def test_set_gender_invalid(self): gender = 'Something else' user = User() with self.assertRaises(TypeError): user.gender = gender