def test_b3_sum_times(self): """[Lab 7] - [Investigation 2] - [Part 1] - Test for sum_times() method in ./lab7d.py""" error_fail = 'sum_times() in lab7d.py contains errors(HINT: review the script and fix errors)' error_output = 'your sum_times() in lab7d.py has an error(HINT: sum_times() does not return correct result)' try: import lab7d as lab7dStudent time1 = lab7dStudent.Time(9, 50, 0) time2 = lab7dStudent.Time(1, 2, 3) sum_t1_t2 = time1.sum_times(time2) result = sum_t1_t2.format_time() except: self.fail(error_fail) answer = '10:52:03' self.assertEqual(result, answer, msg=error_output)
def test_b6_valid_time(self): """[Lab 7] - [Investigation 2] - [Part 1] - Test for valid time using valid_time() method in ./lab7d.py""" error_fail = 'valid_time() in lab7d.py contains errors(HINT: review the script and fix errors)' error_output = 'your valid_time() in lab7d.py has an error(HINT: valild_time() does not return correct result)' try: import lab7d as lab7dStudent time1 = lab7dStudent.Time(9, 50, 59) result = time1.valid_time() except: self.fail(error_fail) answer = True self.assertEqual(result, answer, msg=error_output)
def test_b2_format_time(self): """[Lab 7] - [Investigation 2] - [Part 1] - Test for format_time() method in ./lab7d.py""" error_fail = 'format_time() in lab7d.py contains errors(HINT: review the script and fix errors)' error_output = 'your format_time() in lab7d.py has an error(HINT: format_time() does not return correct values)' try: import lab7d as lab7dStudent time1 = lab7dStudent.Time(9, 50, 0) result = time1.format_time() except: self.fail(error_fail) answer = '09:50:00' self.assertEqual(result, answer, msg=error_output)
def test_b1_time_to_sec(self): """[Lab 7] - [Investigation 2] - [Part 1] - Test for time_to_sec() method in ./lab7d.py""" error_fail = 'time_to_sec() in lab7d.py contains errors(HINT: review the script and fix errors)' error_output = 'your time_to_sec() in lab7d.py has an error(HINT: time_to_sec() does not return correct values)' try: import lab7d as lab7dStudent time1 = lab7dStudent.Time(9, 50, 0) seconds = time1.time_to_sec() except: self.fail(error_fail) answer = 35400 self.assertEqual(seconds, answer, msg=error_output)
def test_b4_change_time(self): """[Lab 7] - [Investigation 2] - [Part 1] - Test for change_time() method in ./lab7d.py""" error_fail = 'change_time() in lab7d.py contains errors(HINT: review the script and fix errors)' error_output = 'your change_time() in lab7d.py has an error(HINT: change_time() does not return correct result)' try: import lab7d as lab7dStudent time1 = lab7dStudent.Time(9, 50, 10) seconds = 1800 none = time1.change_time(seconds) result = time1.format_time() except: self.fail(error_fail) answer = '10:20:10' self.assertEqual(result, answer, msg=error_output)
def test_a_instantiate_class_1(self): """[Lab 7] - [Investigation 2] - [Part 1] - Test for Creating object in ./lab7d.py - should fail with string arguments""" with self.assertRaises(Exception) as context: import lab7d as lab7dStudent objtime = lab7dStudent.Time('hour', 'minute', 'second') x = lab7dStudent.format_time(objtime)
def test_a_instantiate_class_0(self): """[Lab 7] - [Investigation 2] - [Part 1] - Test for Creating object in ./lab7d.py - should fail with 4 arguments""" with self.assertRaises(Exception) as context: import lab7d as lab7dStudent objtime = lab7dStudent.Time(1, 2, 3, 4)