def test_float_or_sympy_evalf(self): # long int long_int = sys.maxsize + 1 self.assertEqual(float_or_sympy_evalf(long_int), long_int) self.assertEqual(float_or_sympy_evalf(1), 1) self.assertEqual(float_or_sympy_evalf(-1), -1) self.assertEqual(float_or_sympy_evalf(0), 0) self.assertEqual(float_or_sympy_evalf(-0.2), -0.2) self.assertEqual(float_or_sympy_evalf(-0.333), -0.333) self.assertEqual(float_or_sympy_evalf("inf"), float("inf"))
def test_float_or_sympy_evalf(self): # long int if six.PY2: long_int = sys.maxint + 1 else: long_int = sys.maxsize + 1 self.assertEqual(float_or_sympy_evalf(long_int), long_int) self.assertEqual(float_or_sympy_evalf(1), 1) self.assertEqual(float_or_sympy_evalf(-1), -1) self.assertEqual(float_or_sympy_evalf(0), 0) self.assertEqual(float_or_sympy_evalf(-0.2), -0.2) self.assertEqual(float_or_sympy_evalf(-0.333), -0.333) self.assertEqual(float_or_sympy_evalf("inf"), float("inf"))
def test_float_or_sympy_evalf_instance_error(self): expected_error_msg = ("expected string, int or float for floating " "point literal") with self.assertRaises(TypeError) as cm: float_or_sympy_evalf([0.5]) self.assertIn(expected_error_msg, str(cm.exception))
def test_float_or_sympy_evalf_value_error(self): expected_error_msg = "can't convert expression to float" with self.assertRaises(TypeError) as cm: float_or_sympy_evalf("abcd") self.assertIn(expected_error_msg, str(cm.exception))
def test_float_or_sympy_evalf_value_empty(self): self.assertEqual(float_or_sympy_evalf(""), "")