- Unit Tests For A Class Assignment A Write Unit Tests To Test The Student Class Class Student Student Class Def 1 (39.65 KiB) Viewed 41 times
Unit Tests for a Class Assignment A Write unit tests to test the Student class: class Student: ***Student class***** def
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Unit Tests for a Class Assignment A Write unit tests to test the Student class: class Student: ***Student class***** def
Unit Tests for a Class Assignment A Write unit tests to test the Student class: class Student: ***Student class***** def __init__(self, 1name, fname, major, gpa=0.0): self.last_name = lname self.first_name = fname self.major = major self.gpa = gpa def_str_(self): return self.last_name Include setUp() and tearDown() methods Write unit test test_object_created_required_attributes(self) • Test constructor values set to only required attributes for acceptable values • Write unit test test_object_created_all_attributes(self) • Test constructor values set to all attributes for acceptable values • Write unit test test_student_str(self) • Test the str() method • Write unit test test_object_not_created_error_last_name(self) that expect exception raised • Add exception to constructor (not in test!) test_object_not_created_error_first_name(self) • Add exception to constructor (not in test!) Write self.first_name + 'has major " + self.major + "with gpa: " + str (self.gpa) • Write test_object_not_created_error_first_name(self) • Add exception to constructor test_object_not_created_error_major(self) • Add exception to constructor test_object_not_created_error_gpa(self) • Add exception to constructor • NOTE: look up how isinstance(gpa, float) works AND check range Write a main() • Create 2 student objects and print them • Write • Write