def test_c_displayStudent(self): """[Lab 6] - [Investigation 1] - [Part 1] - Creating Classes - displayStudent() does not fail if self.number is an integer""" error_fail = 'lab6a.py contains errors(HINT: run the script and fix errors)' error_output = 'your program has an error(HINT: make sure the displayStudent() does not fail when self.number is an integer)' try: import lab6a as lab6aStudent student = lab6aStudent.Student('John', 543210) string1 = student.displayStudent() except: self.fail(error_fail) answer = 'Student Name: John\nStudent Number: 543210' self.assertEqual(string1, answer, msg=error_output)
def test_b1_displayStudent(self): """[Lab 6] - [Investigation 1] - [Part 1] - Creating Classes - displayStudent() provides the correct output""" error_fail = 'lab6a.py contains errors(HINT: run the script and fix errors)' error_output = 'your program has an error(HINT: displayStudent() does not have correct output)' try: import lab6a as lab6aStudent student = lab6aStudent.Student('John', '013454900') string1 = student.displayStudent() except: self.fail(error_fail) answer = 'Student Name: John\nStudent Number: 013454900' self.assertEqual(string1, answer, msg=error_output)
def test_g1_displayCourses(self): """[Lab 6] - [Investigation 1] - [Part 1] - Creating Classes - displayCourses() provides the correct output""" error_fail = 'lab6a.py contains errors(HINT: error occurs when addGrade() never gets run)' error_output = 'your program has an error(HINT: does not have correct output)' try: import lab6a as lab6aStudent student = lab6aStudent.Student('John', '12345') string1 = set(student.displayCourses()) except: self.fail(error_fail) answer = set([]) self.assertEqual(string1, answer, msg=error_output)
def test_e_displayGPA(self): """[Lab 6] - [Investigation 1] - [Part 1] - Creating Classes - displayGPA() handles ZeroDivisionError successfully""" error_fail = 'lab6a.py contains errors(HINT: run the script and fix errors)' error_output = 'your program has an error(HINT: does not have correct output)' try: import lab6a as lab6aStudent student = lab6aStudent.Student('John', '12345') string1 = student.displayGPA() except: self.fail(error_fail) answer = 'GPA of student John is 0.0' self.assertEqual(string1, answer, msg=error_output)
def test_d_displayGPA(self): """[Lab 6] - [Investigation 1] - [Part 1] - Creating Classes - displayGPA() provides the correct output""" error_fail = 'lab6a.py contains errors(HINT: run the script and fix errors)' error_output = 'your program has an error(HINT: does not have correct output)' try: import lab6a as lab6aStudent student = lab6aStudent.Student('John', '12345') student.addGrade('uli101', 4.0) student.addGrade('ipc144', 4.0) string1 = student.displayGPA() except: self.fail(error_fail) answer = 'GPA of student John is 4.0' self.assertEqual(string1, answer, msg=error_output)
def test_a_instantiate_class_1(self): """[Lab 6] - [Investigation 1] - [Part 1] - Creating Classes - instantiating object with 1 arguments fails""" with self.assertRaises(Exception) as context: import lab6a as lab6aStudent student = lab6aStudent.Student('John')