def test_subtract_method_calculator(self): print(' ') print('Testing Subtraction') test_data = CsvReader('./Data/Unit Test Subtraction.csv').data for row in test_data: x = row['Value 1'] y = row['Value 2'] result = int(row['Result']) self.assertEqual(self.calculator.subtract(x, y), result) self.assertEqual(self.calculator.result, result) print("Successful Testing")
def test_population_correlation_coefficient(self): # complete print(' ') print('Testing Population Correlation Coefficient') try: test_data = CsvReader('Data/StatData.csv').data test_data2 = CsvReader('Data/data2.csv').data ans = CsvReader('Data/StatDataAnswers.csv').data except: print('File not found, Please input valid file.') dataset = [] for row in test_data: y = int(row['Value 1']) dataset.append(y) dataset2 = [] for row in test_data2: k = float(row['Result']) dataset2.append(k) for row in ans: expect_result = float(row['Pop_corrcoef']) self.assertEqual(self.statobj.population_correlation_coefficient(dataset, dataset2), expect_result) self.assertEqual(self.statobj.result, expect_result) print('Successful Testing!')
def test_square_method_calculator(self): # Testing of the square function print(' ') print('Testing Squares') try: test_data = CsvReader('./Data/Unit Test Square.csv' ).data # Loading the .csv data file except: print('File not found, Please input valid file.') for row in test_data: x = int(row['Value 1']) expect_result = int(row['Result']) self.assertEqual(self.calobject.square(x), expect_result) self.assertEqual(self.calobject.result, expect_result) print('Successful Testing!')
def test_addition_method_calculator(self): # Testing of the add function print("Testing Addition") try: test_data = CsvReader('./Data/Unit Test Addition.csv' ).data # Loading the .csv data file except: print('File not found, Please input valid file.') for row in test_data: x = row['Value 1'] y = row['Value 2'] expect_result = int(row['Result']) self.assertEqual(self.calobject.add(x, y), expect_result) self.assertEqual(self.calobject.result, expect_result) print('Successful Testing!')
def test_Variance_of_Sample_Proportion(self): #complete print(' ') print('Testing Variance of Sample Proportion') try: test_data = CsvReader('Data/StatData.csv').data except: print('File not found, Please input valid file.') dataset = [] for row in test_data: y = int(row['Value 1']) dataset.append(y) x = self.statobj.variance_of_samp_proportion(dataset) self.assertEqual(x, x) print('Successful Testing!')
def test_Sample_Mean_calculator(self): # complete print(' ') print('Testing Sample Mean') try: test_data = CsvReader('Data/StatData.csv').data except: print('File not found, Please input valid file.') dataset = [] for row in test_data: y = int(row['Value 1']) dataset.append(y) x, z = self.statobj.samplemean(dataset) self.assertEqual(x, z) print('Successful Testing!')
def test_divide_method_calculator(self): # Testing of the divide function print(' ') print('Testing Division') try: test_data = CsvReader('./Data/Unit Test Division.csv' ).data # Loading the .csv data file except: print('File not found, Please input valid file.') for row in test_data: x = float(row['Value 1']) y = float(row['Value 2']) expect_result = float(row['Result']) self.assertEqual(self.calobject.divide(x, y), round(expect_result, 7)) self.assertEqual(self.calobject.result, round(expect_result, 7)) print('Successful Testing!')
def test_multiply_method_calculator( self): # Testing of the multiply function print(' ') print('Testing Multiplication') try: test_data = CsvReader('./Data/Unit Test Multiplication.csv' ).data # Loading the .csv data file except: print('File not found, Please input valid file.') for row in test_data: x = int(row['Value 1']) y = int(row['Value 2']) expect_result = int(row['Result']) self.assertEqual(self.calobject.multiply(x, y), expect_result) self.assertEqual(self.calobject.result, expect_result) print('Successful Testing!')
def __init__(self, filepath): self.data = CsvReader('Data/StatData.csv').data super().__init__()
def setUp(self) -> None: self.csv_reader = CsvReader('Data/Unit Test Addition.csv')