示例#1
0
 def test_squared(self):
     test_data = CSVReader(
         '/Tests/Data_Calculator/Unit Test Square.csv').data
     for row in test_data:
         self.assertEqual(self.calculator.squared(row['Value 1']),
                          int(row['Result']))
         self.assertEqual(self.calculator.result, int(row['Result']))
     test_data.clear()
 def test_mean(self):
     test_data = CSVReader('/Tests/Data_Statistics/Mean_Data.csv').data
     for row in test_data:
         self.assertEqual(
             self.Statistics.mean(row['Value1'], row['Value2'],
                                  row['Value3'], row['Value4'],
                                  row['Value5']), float(row['Mean']))
         self.assertEqual(self.Statistics.result, float(row['Mean']))
     test_data.clear()
示例#3
0
 def test_multiplication(self):
     test_data = CSVReader(
         '/Tests/Data_Calculator/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']))
     test_data.clear()
 def test_root(self):
     test_data = CSVReader(
         '/Tests/Data_Calculator/Unit Test Square Root.csv').data
     for row in test_data:
         self.assertAlmostEqual(self.calculator.root(row['Value 1']),
                                round(float(row['Result']), 9))
         self.assertAlmostEqual(round(float(row['Result']), 9),
                                round(self.calculator.result, 9))
     test_data.clear()
示例#5
0
 def test_conf_int(self):
     test_data = CSVReader('/Tests/Data_PopSampling/ConfInt_Data.csv').data
     for row in test_data:
         self.assertEqual(
             self.PopSampling.conf_int(row['a'], row['b'], row['c'],
                                       row['d'], row['e']),
             float(row['ConfInt']))
         self.assertEqual(self.PopSampling.result, float(row['ConfInt']))
     test_data.clear()
示例#6
0
 def test_margin(self):
     test_data = CSVReader('/Tests/Data_PopSampling/Margin_Data.csv').data
     for row in test_data:
         self.assertEqual(
             self.PopSampling.margin(row['Value1'], row['Value2'],
                                     row['Value3'], row['Value4'],
                                     row['Value5']), float(row['Error']))
         self.assertEqual(self.PopSampling.result, float(row['Error']))
     test_data.clear()
示例#7
0
 def test_cochran(self):
     test_data = CSVReader('/Tests/Data_PopSampling/Cochran_Data.csv').data
     for row in test_data:
         #pprint(self.PopSampling.cochran(row['Z'], row['p'], row['q'], row['e']))
         self.assertEqual(
             self.PopSampling.cochran(row['Z'], row['p'], row['q'],
                                      row['e']), int(row['Sample']))
         self.assertEqual(self.PopSampling.result, int(row['Sample']))
     test_data.clear()
 def test_mode(self):
     test_data = CSVReader('/Tests/Data_Statistics/Mode_Data.csv').data
     #pprint(test_data)
     for row in test_data:
         self.assertEqual(
             self.Statistics.mode(row['Value1'], row['Value2'],
                                  row['Value3'], row['Value4'],
                                  row['Value5']), int(row['Mode']))
         self.assertEqual(self.Statistics.result, int(row["Mode"]))
     test_data.clear()
示例#9
0
 def test_division(self):
     test_data = CSVReader(
         '/Tests/Data_Calculator/Unit Test Division.csv').data
     for row in test_data:
         self.assertAlmostEqual(
             float(row['Result']),
             self.calculator.divide(row['Value 1'], row['Value 2']))
         self.assertAlmostEqual(float(row['Result']),
                                round(self.calculator.result, 9))
     test_data.clear()
示例#10
0
 def test_find_sample_size(self):
     test_data = CSVReader(
         '/Tests/Data_PopSampling/FindSample_Data.csv').data
     for row in test_data:
         self.assertEqual(
             self.PopSampling.find_sample_size(row['P'], row['q'],
                                               row['za2'], row['e']),
             int(row['Sample']))
         self.assertEqual(self.PopSampling.result, int(row['Sample']))
     test_data.clear()
 def test_z_score(self):
     test_data = CSVReader('/Tests/Data_Statistics/ZScore_Data.csv').data
     #pprint(test_data)
     for row in test_data:
         self.assertEqual(
             self.Statistics.z_score(row['Score'], row['Mean'],
                                     row['StDev']),
             round(float(row['Z-Score']), 2))
         self.assertEqual(self.Statistics.result,
                          round(float(row['Z-Score']), 2))
     test_data.clear()
 def test_variance(self):
     test_data = CSVReader('/Tests/Data_Statistics/Variance_Data.csv').data
     #pprint(test_data)
     for row in test_data:
         self.assertEqual(
             self.Statistics.variance(row['Value1'], row['Value2'],
                                      row['Value3'], row['Value4'],
                                      row['Value5']),
             round(float(row['Variance']), 2))
         self.assertEqual(self.Statistics.result,
                          round(float(row['Variance']), 2))
     test_data.clear()
 def test_standard_deviation(self):
     test_data = CSVReader(
         '/Tests/Data_Statistics/Standard_Deviation_Data.csv').data
     #pprint(test_data)
     for row in test_data:
         self.assertEqual(
             self.Statistics.standard_deviation(row['Value1'],
                                                row['Value2'],
                                                row['Value3'],
                                                row['Value4'],
                                                row['Value5']),
             round(float(row['StDev']), 2))
         self.assertEqual(self.Statistics.result,
                          round(float(row['StDev']), 2))
     test_data.clear()
示例#14
0
 def test_multiply_method(self):
     sub_data = CSVReader('csv/Unit Test Multiplication.csv')
     for row in sub_data.data:
         self.assertEqual(
             self.calculator.multiply(int(row['Value 2']),
                                      int(row['Value 1'])),
             int(row['Result']))
示例#15
0
 def test_subtract_method(self):
     sub_data = CSVReader('csv/Unit Test Subtraction.csv')
     for row in sub_data.data:
         self.assertEqual(
             self.calculator.subtract(int(row['Value 2']),
                                      int(row['Value 1'])),
             int(row['Result']))
示例#16
0
 def test_divide_method(self):
     sub_data = CSVReader('csv/Unit Test Division.csv')
     for row in sub_data.data:
         self.assertEqual(
             round(
                 self.calculator.divide(float(row['Value 2']),
                                        float(row['Value 1'])), 9),
             float(row['Result']))
示例#17
0
class MyTestCase(unittest.TestCase):

        def setUp(self) -> None:
            self.csv_reader = CSVReader('addition.txt')

        def test_return_data_as_objects(self):
            people - self.csv_reader.return_data_as_objects('person')
            self.asserIsInstance(people, list)
            test_class = ClassFactory('person', self.csv_reader.data[0])
            for person in people:
                self.asserEqual(person.__name__, test_class.__name__)
示例#18
0
 def setUp(self) -> None:
     self.csv_reader = CSVReader('addition.txt')
示例#19
0
 def test_sqrt_method(self):
     sub_data = CSVReader('csv/Unit Test Square Root.csv')
     for row in sub_data.data:
         self.assertEqual(
             round(self.calculator.square_root(float(row['Value 1'])), 8),
             round(float(row['Result']), 8))
示例#20
0
 def test_square_method(self):
     sub_data = CSVReader('csv/Unit Test Square.csv')
     for row in sub_data.data:
         self.assertEqual(self.calculator.square(int(row['Value 1'])),
                          int(row['Result']))
示例#21
0
 def test_add_method(self):
     add_data = CSVReader('csv/Unit Test Addition.csv')
     for row in add_data.data:
         self.assertEqual(
             self.calculator.add(int(row['Value 1']), int(row['Value 2'])),
             int(row['Result']))
示例#22
0
 def setUp(self):
     self.csv_reader = CSVReader('csv/Unit Test Addition.csv')