def test_multiple_calculators(self): calculator1 = Calculator() calculator2 = Calculator() calculator3 = Calculator() calculator3.addition(calculator1.addition(1, 2), calculator2.subtraction(3, 4)) self.assertEqual(2, calculator3.result)
class MyTestCase(unittest.TestCase): def setUp(self): self.calculator = Calculator() def test_setUp(self): self.assertIsInstance(self.calculator, Calculator) def test_calc_return_add(self): result = self.calculator.addition(1, 2) self.assertEqual(3, result) def test_calc_return_sub(self): result = self.calculator.subtraction(1, 2) self.assertEqual(-1, result) def test_calc_access_sum_result(self): self.calculator.addition(1, 2) self.assertEqual(3, self.calculator.result) def test_calc_access_sub_result(self): self.calculator.subtraction(1, 2) self.assertEqual(-1, self.calculator.result) def test_calc_return_times(self): result = self.calculator.multiplication(3, 2) self.assertEquals(6, result) def test_calc_return_divide(self): result = self.calculator.divide(4, 2) self.assertEquals(2, result) def test_calc_return_exp(self): result = self.calculator.exponentiate(3, 4) self.assertEquals(81, result) def test_calc_return_logged(self): result = self.calculator.logger(10, 10) self.assertEquals(1.0, result) def test_calc_return_nthRoot(self): result = self.calculator.nthRoot(4, 81) self.assertEquals(3.0, result) def test_multiple_calculators(self): calculator1 = Calculator() calculator2 = Calculator() self.calculator.addition(calculator1.addition(1, 2), calculator2.subtraction(3, 4)) self.assertEqual(2, self.calculator.result)
def test_calculator_addition(self): calculator = Calculator() result = calculator.addition(1, 2) self.assertEqual(3, result)
class MyTestCase(unittest.TestCase): def setUp(self) -> None: self.calculator = Calculator() def test_instantiate_calculator(self): self.assertIsInstance(self.calculator, Calculator) def test_addition(self): test_data = CsvReader('Tests/Data/Test_Addition.csv').data #pprint(test_data) for row in test_data: self.assertEqual( self.calculator.addition( [int(row['Value 1']), int(row['Value 2'])]), int(row['Result'])) self.assertEqual(self.calculator.result, int(row['Result'])) def test_subtraction(self): test_data = CsvReader('Tests/Data/Test_Subtraction.csv').data #pprint(test_data) for row in test_data: self.assertEqual( self.calculator.subtraction(int(row['Value 1']), int(row['Value 2'])), int(row['Result'])) self.assertEqual(self.calculator.result, int(row['Result'])) def test_multiplication(self): test_data = CsvReader('Tests/Data/Test_Multiplication.csv').data #pprint(test_data) for row in test_data: self.assertEqual( self.calculator.multiplication(int(row['Value 1']), int(row['Value 2'])), int(row['Result'])) self.assertEqual(self.calculator.result, int(row['Result'])) def test_division(self): test_data = CsvReader('Tests/Data/Test_Division.csv').data #pprint(test_data) for row in test_data: self.assertEqual( self.calculator.division(int(row['Value 1']), int(row['Value 2'])), float(row['Result'])) self.assertEqual(self.calculator.result, float(row['Result'])) def test_Square(self): test_data = CsvReader('Tests/Data/Test_Square.csv').data #pprint(test_data) for row in test_data: self.assertEqual(self.calculator.square(int(row['Value 1'])), int(row['Result'])) self.assertEqual(self.calculator.result, int(row['Result'])) def test_SquareRoot(self): test_data = CsvReader('Tests/Data/Test_SquareRoot.csv').data #pprint(test_data) for row in test_data: self.assertEqual(self.calculator.square_root(int(row['Value 1'])), float(row['Result'])) self.assertEqual(self.calculator.result, float(row['Result']))
def test_calc_add(self): calculator = Calculator() calculator.addition(1, 2) self.assertEqual(3, calculator.result)
class MyTestCase(unittest.TestCase): def setUp(self): self.calculator = Calculator() def test_instantiate_calculator(self): self.assertIsInstance(self.calculator, Calculator) def test_calculator_addition(self): result = self.calculator.addition(1, 2) self.assertEqual(3, result) def test_calculator_subtraction(self): result = self.calculator.subtraction(4, 2) self.assertEqual(2, result) def test_calculator_multiplication(self): result = self.calculator.multiplication(2, 2) self.assertEqual(4, result) def test_calculator_division(self): result = self.calculator.division(3, 1) self.assertEqual(3, result) def test_calculator_squareroot(self): result = self.calculator.squareroot(4) self.assertEqual(2, result) def test_calculator_square(self): result = self.calculator.square(2) self.assertEqual(4, result) def test_calculator_access_Addition_result(self): self.calculator.addition(1, 2) self.assertEqual(3, self.calculator.result) def test_calculator_access_subtraction_result(self): self.calculator.subtraction(1, 2) self.assertEqual(-1, self.calculator.result) def test_MathOperations_sum_list(self): valuelist = [1, 2, 3] self.assertEqual(6, Addition.sum(valuelist)) def test_MathOperations_difference_list(self): valuelist = [1, 2, 3] self.assertEqual(-4, Difference.difference(valuelist)) def test_calculator_access_multiply_result(self): self.calculator.multiplication(2, 2) self.assertEqual(4, self.calculator.result) def test_MathOperations_multiply_list(self): valuelist = [1, 2, 3] self.assertEqual(6, Multiply.multiply(valuelist)) def test_calculator_access_divide_result(self): self.calculator.division(4, 2) self.assertEqual(2, self.calculator.result) def test_calculator_access_squareRoot_result(self): self.calculator.squareroot(4) self.assertEqual(2, self.calculator.result) def test_calculator_access_square_result(self): self.calculator.square(2) self.assertEqual(4, self.calculator.result) def test_MathOperations_divide_list(self): valuelist = [8, 2, 2] self.assertEqual(2, Divide.divide(valuelist)) def test_multiple_calculators(self): calculator1 = Calculator() calculator2 = Calculator() self.calculator.addition(calculator1.addition(1, 2), calculator2.subtraction(3, 4)) self.assertEqual(2, self.calculator.result)