def test_10_power_x_inverse(self):
     """This function is used to test for the inverse of scientific operation
     10 power x"""
     calculate_ten_power = ScientificCalc()
     value = calculate_ten_power.cal_power_ten(2)
     inverse = math.log10(value)
     self.assertEqual(inverse, 2)
Exemplo n.º 2
0
def main():
    """This main method is used to call the scientific operation 10 power x"""
    try:
        power_x_obj = ScientificCalc()
        parser = argparse.ArgumentParser()
        parser.add_argument('--function', type=str, required=True, nargs='+')
        args = parser.parse_args()
        method_name = args.function
        if method_name[0] == 'cal_power_ten':
            power_val = method_name[1]
            print(power_x_obj.cal_power_ten(power_val))

    except ValueError as value_error:
        logging.error(value_error)
        print('Error has occured')
 def test_10_power_x_exception_power(self):
     """This function is used to unit test the scientific operation 10 power
     for negative_float power value"""
     calculate_ten_power = ScientificCalc()
     with self.assertRaises(ValueError):
         calculate_ten_power.cal_power_ten('accenture')
 def test_10_power_x_neg_dec_power(self):
     """This function is used to unit test the scientific operation 10 power x
     for negative_float power value"""
     calculate_ten_power = ScientificCalc()
     self.assertEqual(calculate_ten_power.cal_power_ten(-2.2), 10**(-2.2))
 def test_10_power_x_zero_power(self):
     """This function is used to unit test the scientific operation 10 power x
     for zero power value"""
     calculate_ten_power = ScientificCalc()
     self.assertEqual(calculate_ten_power.cal_power_ten(0), 10**0)
 def test_pos_power(self):
     """This function is used to unit test the scientific operation 10 power x
      for positive power value"""
     calculate_ten_power = ScientificCalc()
     self.assertEqual(calculate_ten_power.cal_power_ten(2), 10**2)