def test_float_to_int_unqualified_field(self) -> None: with self.assertRaises(TypeError): numerical( # type: ignore req_int_val=5, req_float_val=math.pi, int_val=math.pi )
def test_float_to_int_list(self) -> None: with self.assertRaises(TypeError): numerical( req_int_val=5, req_float_val=math.pi, int_list=[math.pi, math.e], # type: ignore )
def test_float_to_int_unqualified_field(self) -> None: with self.assertRaises(TypeError): numerical( float_val=math.pi, # pyre-fixme[6]: Expected `Optional[int]` for 3rd param but got `float`. int_val=math.pi, )
def test_float_to_int_list(self) -> None: with self.assertRaises(TypeError): numerical( req_int_val=5, req_float_val=math.pi, # pyre-fixme[6]: Expected `Optional[typing.Sequence[int]]` for 3rd # param but got `List[float]`. int_list=[math.pi, math.e], )
def test_int_to_float(self) -> None: x = numerical(req_int_val=5, req_float_val=5, float_val=5, float_list=[1, 5, 6]) x(req_float_val=10) x(float_val=10) x(float_list=[6, 7, 8])
def test_float_to_int_required_field(self) -> None: with self.assertRaises(TypeError): # pyre-fixme[6]: Expected `Optional[int]` for 1st param but got `float`. numerical(req_int_val=math.pi, req_float_val=math.pi)
def test_int_to_i64(self) -> None: large = 2**63 - 1 numerical(req_int_val=5, req_float_val=5, i64_val=int(large)) too_large = 2**65 - 1 with self.assertRaises(OverflowError): numerical(req_int_val=5, req_float_val=5, i64_val=int(too_large))
def test_overflow(self) -> None: with self.assertRaises(OverflowError): numerical(req_float_val=5, req_int_val=2**63 - 1) with self.assertRaises(OverflowError): numerical(req_float_val=5, req_int_val=2, int_list=[5, 2**32])
def test_float_to_int_required_field(self) -> None: with self.assertRaises(TypeError): numerical(req_int_val=math.pi, req_float_val=math.pi) # type: ignore
def test_overflow(self) -> None: with self.assertRaises(OverflowError): numerical(req_float_val=5, req_int_val=2 ** 63 - 1) with self.assertRaises(OverflowError): numerical(req_float_val=5, req_int_val=2, int_list=[5, 2 ** 32])