コード例 #1
0
 def test_root(self):
     test_data5 = CsvReader('/src/TestFile/Root.csv').data
     for row in test_data5:
         self.assertEqual(self.calculator.squareroot(row['Value 1']),
                          round(float(row['Result']), 8))
         self.assertEqual(self.calculator.result,
                          round(float(row['Result']), 8))
コード例 #2
0
 def test_addition(self):
     test_data = CsvReader('/src/Addition.csv').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']))
コード例 #3
0
 def test_subtraction(self):
     self.test_data = CsvReader('/src/Subtraction.csv').data
     for row in self.test_data:
         self.assertEqual(self.calculator.subtract(int(row['Value 1']), int(row['Value 2'])), int(row['Result']))
         self.assertEqual(self.calculator.result, int(row['Result']))
         print(self.calculator.result)
     print("------------------Subtraction-------------------")
コード例 #4
0
 def test_sqrt_method_calculator(self):
     test_data_sqrt = CsvReader('/src/Square Root.csv').data
     for row in test_data_sqrt:
         self.assertEqual(self.calculator.sqrt(float(row['Value 1'])),
                          round(float(row['Result']), 8))
         self.assertEqual(self.calculator.result,
                          round(float(row['Result']), 8))
def readDataset():
    '''
		This makes the input calls to have the paths to the dataset and the header.
		It will return the CvsReader Class with the dataset and the header.
	'''
    parentPath = str(Path(__file__).resolve().parents[1])

    filename_data = input(
        "Please write the relative path of you dataset file (i.e. \"Car/data.csv\"): "
    )
    filename_data = os.path.join(parentPath, "Datasets", filename_data)

    filename_header = input(
        "Please write the relative path of you dataset file (i.e. \"Car/header.csv\"): "
    )
    filename_header = os.path.join(parentPath, "Datasets", filename_header)

    numericIndex = input(
        "Insert the indexes of the columns that are numerics, if any. Divide the index with a ,(comma): "
    )

    numericIndex = numericIndex.split(",")
    #print ("Empty: "+str(numericIndex))
    if (len(numericIndex) > 0 and not numericIndex[0] == ''):
        numericIndex = [int(i) for i in numericIndex]
        print(numericIndex)
        #print("len of num: "+str(len(numericIndex)))
    else:
        numericIndex = None

    dataset = CsvReader(filename_data, filename_header, numericIndex)
    return dataset
コード例 #6
0
 def test_addition(self):
     test_data = CsvReader.CsvReader('Tests/Data/TestAddition.csv').data
     for row in test_data:
         result = float(row['Result'])
         self.assertEqual(
             self.calculator.add(row['Value 1'], row['Value 2']), result)
         self.assertEqual(self.calculator.result, int(row['Result']))
コード例 #7
0
 def test_square(self):
     test_data = CsvReader('/src/Square.csv').data
     for row in test_data:
         result = float(row['Result'])
         self.assertEqual(self.calculator.sqr(float(row['Value 1'])),
                          result)
         self.assertEqual(self.calculator.result, result)
コード例 #8
0
 def test_addition(self):
     test_data = CsvReader('Test-scripts/Unit Test Addition.csv').data
     for row in test_data:
         self.assertEqual(
             self.calculator.add(row['Value 1'], row['Value 2']),
             float(row['Result']))
         self.assertEqual(self.calculator.result, float(row['Result']))
コード例 #9
0
 def test_square_root(self):
     test_data = CsvReader('csvFiles/squareRoot.csv').data
     for row in test_data:
         self.assertEqual(self.calculator.square_root(int(row['Value 1'])),
                          format(float(row['Result']), '.7f'))
         self.assertEqual(self.calculator.result,
                          format(float(row['Result']), '.7f'))
コード例 #10
0
 def test_division(self):
     test_data = CsvReader("src/UnitTestDivision.csv").data
     for row in test_data:
         result = float(row['Result'])
         self.assertEqual(
             self.calculator.divide(row['Value 1'], row['Value 2']), result)
         self.assertEqual(self.calculator.result, result)
コード例 #11
0
 def test_squareroot(self):
     test_data = CsvReader("src/UnitTestSquareRoot.csv").data
     for row in test_data:
         result = float(row['Result'])
         self.assertEqual(self.calculator.square_root(row['Value 1']),
                          result)
         self.assertEqual(self.calculator.result, result)
コード例 #12
0
 def test_squareroot(self):
     test_data = CsvReader('./src/squareroot.csv').data
     for row in test_data:
         self.assertEqual(
             self.calculator.squareroot(row['Value 1'], row['Value 2']),
             int(row['Result']))
         self.assertEqual(self.calculator.result, int(row['Result']))
コード例 #13
0
ファイル: CalculatorTests.py プロジェクト: vp373/Calculator
 def test_sqrt_method_calculator(self):
     test_data = CsvReader('/src/Sqrt.csv').data
     for row in test_data:
         self.assertAlmostEqual(self.calculator.sqrt(row['Value 1'], ),
                                float(row['Result']))
         self.assertAlmostEqual(self.calculator.result,
                                float(row['Result']))
コード例 #14
0
 def test_multiplication(self):
     test_data = CsvReader("/CSVFiles/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)
コード例 #15
0
 def test_multiply(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']))
コード例 #16
0
 def test_squareroot_method_calculator(self):
     test_data = CsvReader('src/UnitTestSquareRoot.csv').data
     for row in test_data:
         result = float(row['Result'])
         self.assertAlmostEqual(
             self.calculator.squareroot(float(row['Value 1'])), result)
         self.assertAlmostEqual(self.calculator.result, result)
コード例 #17
0
 def test_square(self):
     test_data = CsvReader('/src/Square.csv').data
     for row in test_data:
         self.assertEqual(int(row['Result']),
                          self.calculator.sqr(row['Value 1']))
         self.assertEqual(int(row['Result']), self.calculator.result)
     test_data.clear()
コード例 #18
0
 def test_MultiplicationFromFile(self):
     test_dataM = CsvReader('./src/Multiplication.csv').data
     for row in test_dataM:
         result = float(row['Result'])
         self.assertEqual(
             self.calculator.multiply(row['Value 1'], row['Value 2']),
             result)
コード例 #19
0
 def test_division_method_calculator(self):
     test_data = CsvReader("/CSVFiles/Unit_Test_Division.csv").data
     for row in test_data:
         result = float(row['Result'])
         self.assertEqual(
             self.calculator.divide(row['Value 1'], row['Value 2']), result)
         self.assertEqual(self.calculator.result, result)
コード例 #20
0
 def test_DividisionFromFile(self):
     test_dataD = CsvReader('./src/Division.csv').data
     for row in test_dataD:
         result = float(row['Result'])
         self.assertEqual(
             round(self.calculator.divide(row['Value 2'], row['Value 1']),
                   9), result)
コード例 #21
0
 def test_squareroot(self):
     test_data = CsvReader('/src/SquareRoot.csv').data
     for row in test_data:
         result = round(float(row['Result']), 8)
         self.assertEqual(self.calculator.sqrt(float(row['Value 1'])),
                          result)
         self.assertEqual(self.calculator.result, result)
コード例 #22
0
 def test_squareRoot_method_calculator(self):
     test_data = CsvReader('/src/Unit_test_square_root.csv').data
     pprint(test_data)
     for row in test_data:
         self.assertEqual(self.calculator.squareRoot(row['Value 1']),
                          float(row['Result']))
         self.assertEqual(self.calculator.result, float(row['Result']))
コード例 #23
0
 def test_add_method_calculator(self):
     test_data = CsvReader("./src/Unit 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']))
コード例 #24
0
 def test_square_root_csv(self):
     test_data = CsvReader('./src/tests/square_root.csv').data
     for row in test_data:
         self.assertEqual(self.calculator.square_root(row['Value 1']),
                          round(float(row['Result']), 9))
         self.assertEqual(self.calculator.result,
                          round(float(row['Result']), 9))
コード例 #25
0
    def test_square_method_calculator(self):
        test_data = CsvReader("/CSVFiles/Unit_Test_Square.csv").data

        for row in test_data:
            result = float(row['Result'])
            self.assertEqual(self.calculator.square(row['Value 1'], ), result)
            self.assertEqual(self.calculator.result, result)
コード例 #26
0
 def test_square_method_calculator(self):
     square_test_data = CsvReader('/src/Unit Test Square.csv').data
     for row in square_test_data:
         self.assertEqual(self.calculator.square(row['Value 1']),
                          int(row['Result']))
         self.assertEqual(self.calculator.result, int(row['Result']))
     square_test_data.clear()
コード例 #27
0
 def test_division(self):
     test_data = CsvReader('/src/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']))
コード例 #28
0
 def test_subtract(self):
     test_data = CsvReader('/src/Unit Test Subtraction.csv').data
     for row in test_data:
         self.assertEqual(
             self.calculator.Subtraction(row['Value 1'], row['Value 2']),
             int(row['Result']))
         self.assertEqual(self.calculator.result, int(row['Result']))
コード例 #29
0
 def test_multiplication(self):
     self.test_data = CsvReader('/src/Multiplication.csv').data
     for row in self.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']))
         print(self.calculator.result)
     print("------------------Multiplication-------------------")
コード例 #30
0
 def test_subtraction(self):
     test_data3 = CsvReader('/src/TestFile/subtraction.csv').data
     for row in test_data3:
         self.assertEqual(
             self.calculator.subtract(row['Value 1'], row['Value 2']),
             int(row['Result']))
         self.assertEqual(self.calculator.result, int(row['Result']))