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)
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_square_root_positive(self): """test case for positive value""" test = ScientificCalc() self.assertEqual(test.square_root(4), 2.0)
def test_e_power_x_zero_exp(self): "When the input is zero" obj_exp = ScientificCalc() self.assertEqual(obj_exp.exponential_func(0), 2.71828182846 ** 0)
def test_tanh_integer(self): """test case for tanh(4)""" calc = ScientificCalc() self.assertEqual(calc.calculate_tanh(4), 0.9993292997390669)
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_tanh_fnegative(self): """test case for tanh(-55.7)""" calc = ScientificCalc() self.assertEqual(calc.calculate_tanh(-55.7), -1.0)
def test_type_exception(self): scientificcalc = ScientificCalc() self.assertRaises(TypeError, scientificcalc.calculate_cos('angle'))
def test_tanh_negative(self): """test case for tanh(-14)""" calc = ScientificCalc() self.assertEqual(calc.calculate_tanh(-14), -0.9999999999986172)
def test_rad_posfloat(self): '''check for positive float ''' calc = ScientificCalc() self.assertAlmostEqual(calc.rad(2.5), 0.04363323129985824)
def test_rad_negative(self): '''check for negative integers''' calc = ScientificCalc() self.assertEqual(calc.rad(-1), -0.017453292519943295)
def test_rad_positive(self): '''check for positive integers''' calc = ScientificCalc() self.assertEqual(calc.rad(1), 0.017453292519943295)
def test_rad_zero(self): '''check for zero''' calc = ScientificCalc() self.assertEqual(calc.rad(0), 0)
def test_square_root_string(self): """test case if we give string""" test = ScientificCalc() self.assertEqual(test.square_root("a"), "expecting integer value")
def test_square_root_negative(self): """test case for negative value""" test = ScientificCalc() self.assertEqual(test.square_root(-8), complex(1.7319121124709868e-16 + 2.8284271247461903j))
def test_negative_angle_values(self): scientificcalc = ScientificCalc() self.assertEqual(-0.7596879128588213, scientificcalc.calculate_cos(-15))
def test_float_angle_values(self): scientificcalc = ScientificCalc() self.assertEqual(0.6090559761063562, scientificcalc.calculate_cos(30.5))
def test_rad_negfloat(self): '''check for negative float''' calc = ScientificCalc() self.assertEqual(calc.rad(-4.5), -0.07853981633974483)
def test_tanh_float(self): """test case for tanh(8.9)""" calc = ScientificCalc() self.assertEqual(calc.calculate_tanh(8.1), 0.9999998157280002)
def test_rad_string(self): '''check for exception''' calc = ScientificCalc() self.assertEqual(calc.rad("abc"), "Value Error")
def test_tanh_string(self): """test case for tanh(-55.7)""" calc = ScientificCalc() self.assertEqual(calc.calculate_tanh("sss"), "value error(enter a number)")
def test_one_by_x_value(self): """input=1""" calc = ScientificCalc() res = calc.one_by_x(1) self.assertEqual(res, 1)
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_one_by_x_zero_division_error(self): """input=0""" calc = ScientificCalc() self.assertEqual(calc.one_by_x(0), "ZeroDivisionError")
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_one_by_x_value_error(self): """input=giving string instead of number""" calc = ScientificCalc() result = calc.one_by_x("s") self.assertEqual(result, "ValueError")
def test_e_power_x_negative_exp(self): "When the input is negative integer" obj_exp = ScientificCalc() self.assertEqual(obj_exp.exponential_func(-2), 2.71828182846 ** -2)
def test_one_by_x_value5(self): """when we take 5 as input""" calc = ScientificCalc() result = calc.one_by_x(5) self.assertEqual(result, 0.2)
def main(): scientificcalc = ScientificCalc() angle = float(sys.argv[1]) print(scientificcalc.calculate_cos(angle))
def test_positive_angle_values(self): scientificcalc = ScientificCalc() self.assertEqual(0.15425144988758405, scientificcalc.calculate_cos(30))