Пример #1
0
 def test_j_function_multiply_output(self):
     """[Lab 3] - [Investigation 2] - [Part 1] - functions & arguments & logic - function operate() fails with division"""
     # Try to import before testing
     try:
         import lab3c as lab3cStudent
     except:
         self.fail(
             'lab3c.py contains errors(HINT: run the function and fix errors'
         )
     error_output = 'function operate shows wrong output(HINT: the output must match exactly)'
     self.assertEqual(
         str(lab3cStudent.operate(5, 50, 'divide')),
         'Error: function operator can be "add", "subtract", or "multiply"')
Пример #2
0
 def test_h_function_subtract_output(self):
     """[Lab 3] - [Investigation 2] - [Part 1] - functions & arguments & logic - function operate() subtracts correctly test 2"""
     # Try to import before testing
     try:
         import lab3c as lab3cStudent
     except:
         self.fail(
             'lab3c.py contains errors(HINT: run the function and fix errors'
         )
     error_output = 'problem subtracting(HINT: operate(5, 50, \'subtract\')'
     self.assertEqual(str(lab3cStudent.operate(5, 50, 'subtract')),
                      '-45',
                      msg=error_output)
Пример #3
0
 def test_i_function_multiply_output(self):
     """[Lab 3] - [Investigation 2] - [Part 1] - functions & arguments & logic - function operate() multiplies correctly test 2"""
     # Try to import before testing
     try:
         import lab3c as lab3cStudent
     except:
         self.fail(
             'lab3c.py contains errors(HINT: run the function and fix errors'
         )
     error_output = 'problem multiplying(HINT: operate(5, 50, \'multiply\')'
     self.assertEqual(str(lab3cStudent.operate(5, 50, 'multiply')),
                      '250',
                      msg=error_output)
Пример #4
0
 def test_d_function_sum_output(self):
     """[Lab 3] - [Investigation 2] - [Part 1] - functions & arguments & logic - function operate() adds correctly test 1"""
     # Try to import before testing
     try:
         import lab3c as lab3cStudent
     except:
         self.fail(
             'lab3c.py contains errors(HINT: run the function and fix errors'
         )
     error_output = 'problem adding(HINT: operate(10, 5, \'add\')'
     self.assertEqual(str(lab3cStudent.operate(10, 5, 'add')),
                      '15',
                      msg=error_output)