Пример #1
0
 def test_none_validates(self):
     nm = NumberMeta("int32")
     assert 0 == nm.validate(None)
Пример #2
0
 def test_unsigned_validates(self):
     nm = NumberMeta("uint32")
     assert nm.validate("22") == 22
     assert nm.validate(-22) == 2**32 - 22
Пример #3
0
 def test_float_to_int_truncates(self):
     nm = NumberMeta("int32")
     assert nm.validate(123.6) == 123
Пример #4
0
 def test_int_against_int(self):
     nm = NumberMeta("int32")
     assert 123 == nm.validate(123)
Пример #5
0
 def test_int_against_float(self):
     nm = NumberMeta("float64")
     assert 123 == nm.validate(123)
Пример #6
0
 def test_float_against_float64(self):
     nm = NumberMeta("float64")
     assert 123.456 == nm.validate(123.456)
Пример #7
0
 def test_float_against_float32(self):
     nm = NumberMeta("float32")
     self.assertAlmostEqual(123.456, nm.validate(123.456), places=5)