def test_subtract_method_calculator(self): test_data = CsvReader('/src/Unit Test Subtraction.csv').data for row in test_data: self.assertEqual( self.calculator.subtract(row['Value 1'], row['Value 2']), int(row['Result'])) self.assertEqual(self.calculator.result, int(row['Result']))
def test_square(self): test_data = CsvReader('./src/test_square.csv').data pprint(test_data) for row in test_data: self.assertEqual(self.calculator.squaring(int(row['Value 1'])), int(row['Result'])) self.assertEqual(self.calculator.result, int(row['Result']))
def test_addition(self): test_data = CsvReader('./src/test_addition.csv').data for row in test_data: self.assertEqual( self.calculator.add(int(row['Value 1']), int(row['Value 2'])), int(row['Result'])) self.assertEqual(self.calculator.result, int(row['Result']))
def test_multiply_method_calculator(self): test_data = CsvReader('/src/Unit Test Multiplication.csv').data for row in test_data: self.assertEqual( self.calculator.multiply(row['Value 1'], row['Value 2']), int(row['Result'])) self.assertEqual(self.calculator.result, int(row['Result']))
def test_multiplication(self): calculator = Calculator() testData = CsvReader('src/Unit Test Multiplication.csv').data for row in testData: self.assertEqual( calculator.multiply(int(row['Value 1']), int(row['Value 2'])), int(row['Result']))
def test_sqrroot_method_calculator(self): test_data = CsvReader('/src/Unit Test Square Root.csv').data for row in test_data: self.assertAlmostEqual( self.calculator.squareroot(row['Value 1'], ), float(row['Result'])) self.assertAlmostEqual(self.calculator.result, float(row['Result']))
def test_divide_method_calculator(self): test_data = CsvReader('/src/Unit Test Division.csv').data for row in test_data: self.assertAlmostEqual( self.calculator.divide(row['Value 1'], row['Value 2']), float(row['Result'])) self.assertAlmostEqual(self.calculator.result, float(row['Result']))
def test_subtraction(self): calculator = Calculator() testData = CsvReader('src/Unit Test Subtraction.csv').data for row in testData: #print('Value 1:', row['Value 1'], 'Value 2', row['Value 2'], 'Result', row['Result'], 'Answer', calculator.subtract(int(row['Value 1']), int(row['Value 2']))) self.assertEqual( calculator.subtract(int(row['Value 1']), int(row['Value 2'])), int(row['Result']))
def test_addition(self): calculator = Calculator() testData = CsvReader('src/Unit Test Addition.csv' ).data #.return_data_as_objects('addition') for row in testData: self.assertEqual( calculator.add(int(row['Value 1']), int(row['Value 2'])), int(row['Result']))
def test_square_method_calculator(self): test_data = CsvReader('/src/Unit Test Square.csv').data #pprint(test_data) for row in test_data: self.assertEqual(self.calculator.sqr(row['Value 1']), float(row['Result'])) self.assertEqual(self.calculator.result, float(row['Result'])) test_data.clear()
def test_multiply(self): test_data = CsvReader('./src/test_multiplication.csv').data pprint(test_data) for row in test_data: self.assertEqual( self.calculator.multiply(int(row['Value 1']), int(row['Value 2'])), int(row['Result'])) self.assertEqual(self.calculator.result, int(row['Result']))
def test_addition_method_calculator(self): test_data = CsvReader('/src/Unit Test Addition.csv').data #pprint(test_data) for row in test_data: self.assertEqual( self.calculator.add(row['Value 1'], row['Value 2']), int(row['Result'])) self.assertEqual(self.calculator.result, int(row['Result'])) test_data.clear()
def test_square_root(self): test_data = CsvReader('./src/test_square_root.csv').data pprint(test_data) for row in test_data: self.assertAlmostEqual(self.calculator.sqrt(int(row['Value 1'])), float(row['Result']), places=4) self.assertAlmostEqual(self.calculator.result, float(row['Result']), places=4)
def test_squarerooted(self): calculator = Calculator() testData = CsvReader('src/Unit Test Square Root.csv').data for row in testData: decimal_at = row['Result'].find('.') precision = len(row['Result']) - decimal_at - 1 if decimal_at == -1: precision = 0 self.assertEqual( round(calculator.squareroot(int(row['Value 1'])), precision), round(float(row['Result']), precision))
def test_sqr_method_calculator(self): test_data = CsvReader('/src/Unit Test Square.csv').data for row in test_data: self.assertEqual(self.calculator.square(row['Value 1'], ), int(row['Result'])) self.assertEqual(self.calculator.result, int(row['Result']))
def test_squared(self): calculator = Calculator() testData = CsvReader('src/Unit Test Square.csv').data for row in testData: self.assertEqual(calculator.square(int(row['Value 1'])), int(row['Result']))