def test_Standard_Deviation_calculator(self): test_data = CsvReader('Tests/Data/statsData.csv').data answer = CsvReader('Tests/Data/answers.csv').data dataset = [] for row in test_data: y = int(row['Value 1']) dataset.append(y) for column in answer: expect_result = float((column['StanDeviation'])) self.assertEqual(self.statobj.stddev(dataset), expect_result) self.assertEqual(self.statobj.result, expect_result)
def test_Variance_calculator(self): test_data = CsvReader('Tests/Data/statsData.csv').data answer = CsvReader('Tests/Data/answers.csv').data dataset = [] for row in test_data: y = int(row['Value 1']) dataset.append(y) for column in answer: expect_result = float((column['Variance'])) self.assertEqual(self.statobj.variance(dataset), expect_result) self.assertEqual(self.statobj.result, expect_result)
def test_z_score_calculator(self): test_data = CsvReader('Tests/Data/statsData.csv').data data_answer = CsvReader('Tests/Data/Zscore.csv').data dataset = [] for row in test_data: y = int(row['Value 1']) dataset.append(y) data_answer1 = [] for row in data_answer: z = float(row["Result"]) data_answer1.append(z) self.assertEqual(self.statobj.z_score(dataset), data_answer1) self.assertEqual(self.statobj.result, data_answer1)
def test_multiplication(self): test_data = CsvReader("Tests/Data/Unit_Test_Calculator.csv").data for row in test_data: result = float(row['Multiply Result']) self.assertEqual(self.calculator.multiply(row['Multiply 1'], row['Multiply 2']), float(row['Multiply Result'])) self.assertEqual(self.calculator.result, result)
def test_sample_mean(self): test_data = CsvReader('Tests/Data/Unit_Test_Statistics.csv').data for row in test_data: result = float(row['smean1']) self.assertEqual(self.statistics.sample_mean(row['ds1_value1'], row['ds1_value2'], row['ds1_value3'], row['ds1_value4'], row['ds1_value5']), result) self.assertEqual(self.statistics.result, result) pprint(test_data)
def test_median(self): test_data = CsvReader('Tests/Data/Unit_Test_Statistics.csv').data for row in test_data: result = float(row['median1']) self.assertEqual(self.statistics.median(row['ds1_value1'], row['ds1_value2'], row['ds1_value3'], row['ds1_value4'], row['ds1_value5'], row['ds1_value6'], row['ds1_value7'], row['ds1_value8'], row['ds1_value9']), result) self.assertEqual(self.statistics.result, result)
def test_standarddeviation(self): test_data = CsvReader('Tests/Data/Unit_Test_Statistics.csv').data for row in test_data: result = float(row['pop_std_dev1']) self.assertEqual(self.statistics.standarddeviation(row['ds1_value1'], row['ds1_value2'], row['ds1_value3'], row['ds1_value4'], row['ds1_value5'], row['ds1_value6'], row['ds1_value7'], row['ds1_value8'], row['ds1_value9'], row['ds1_value10']), result) self.assertEqual(self.statistics.result, result)
class MyTestCase(unittest.TestCase): def setUp(self) -> None: self.csv_reader = CsvReader('Tests/Data/addition.csv') def test_return_data_as_objects(self): people = self.csv_reader.return_data_as_objects('person') self.assertIsInstance(people, list) test_class = ClassFactory('person', self.csv_reader.data[0]) for person in people: self.assertEqual(person.__name__, test_class.__name__)
class MyTestCase(unittest.TestCase): pass def setUp(self) -> None: self.csv_reader = CsvReader( filepath='Tests/Data/Unit_Test_Statistics.csv') def test_return_data_as_objects(self): people = self.csv_reader.return_data_as_objects('Value 1') self.assertIsInstance(people, list) test_class = classfactory('Value 1', self.csv_reader.data[0]) for person in people: self.assertEqual(person.__name__, test_class.__name__)
def test_sqrt(self): test_data = CsvReader("Tests/Data/Unit_Test_Calculator.csv").data for row in test_data: result = float(row['Sqrt Result']) self.assertEqual(self.calculator.sqrt(row['Sqrt 1']), float(row['Sqrt Result'])) self.assertEqual(self.calculator.result, result)
def test_division(self): test_data = CsvReader("Tests/Data/Unit_Test_Calculator.csv").data for row in test_data: result = float(row['Divide Result']) self.assertEqual(self.calculator.division(row['Divide 1'], row['Divide 2']), float(row['Divide Result'])) self.assertEqual(self.calculator.result, result)
def test_subtraction(self): test_data = CsvReader("Tests/Data/Unit_Test_Calculator.csv").data for row in test_data: result = float(row['Sub Result']) self.assertEqual(self.calculator.subtract(row['Sub 1'], row['Sub 2']), float(row['Sub Result'])) self.assertEqual(self.calculator.result, result)
def test_addition(self): test_data = CsvReader("Tests/Data/Unit_Test_Calculator.csv").data for row in test_data: result = float(row['Add Result']) self.assertEqual(self.calculator.add(row['Add 1'], row['Add 2']), float(row['Add Result'])) self.assertEqual(self.calculator.result, result)
def setUp(self) -> None: self.csv_reader = CsvReader('Tests/Data/addition.csv')
def setUp(self) -> None: self.csv_reader = CsvReader( filepath='Tests/Data/Unit_Test_Statistics.csv')
def test_zscore(self): test_data = CsvReader('Tests/Data/Unit_Test_Statistics.csv').data for row in test_data: result = float(row['zscoreresult']) self.assertEqual(self.statistics.zscore(row['ds1_value1'], row['zmean'], row['zstdev']), result) self.assertEqual(self.statistics.result, result)
def test_subtraction(self): test_data = CsvReader('Tests/Data/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_sqrt_cal(self): test_data = CsvReader('Tests/Data/squareRoot.csv').data for row in test_data: self.assertEqual(self.calculator.square_root(row['Value 1']), round(float(row['Result']), 7)) self.assertEqual(self.calculator.result, round(float(row['Result']), 7))
def test_square(self): test_data = CsvReader('Tests/Data/square.csv').data for row in test_data: self.assertEqual(self.calculator.skuare(row['Value 1']), int(row['Result'])) self.assertEqual(self.calculator.result, int(row['Result']))
def test_divide(self): test_data = CsvReader('Tests/Data/division.csv').data for row in test_data: self.assertEqual(self.calculator.divide(row['Value 1'], row['Value 2']), float(row['Result'])) self.assertEqual(self.calculator.result, float(row['Result']))
def test_multiply(self): test_data = CsvReader('Tests/Data/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']))