def test_min_validation(self): instance = create_instance(Integer(min=0)) instance.attr = 0 self.assertEqual(0, instance.attr) with self.assertRaises(ValueError): instance.attr = -1
def test_max_validation(self): instance = create_instance(Integer(max=10)) instance.attr = 10 self.assertEqual(10, instance.attr) with self.assertRaises(ValueError): instance.attr = 11
def test_max_validation(self): instance = create_instance(Integer(max=10)) instance.attr = 10 assert 10 == instance.attr with self.assertRaises(ValueError): instance.attr = 11
def test_numeric_string_disallowed(self): instance = create_instance(Integer()) with self.assertRaises(TypeError): instance.attr = '123'
def test_float_disallowed(self): instance = create_instance(Integer()) with self.assertRaises(TypeError): instance.attr = 123.0
def test_long_allowed(self): instance = create_instance(Integer()) instance.attr = long(123) self.assertEqual(123, instance.attr)
def test_default_handling(self): instance = create_instance(Integer(default=1234)) self.assertEqual(1234, instance.attr)
def test_int_allowed(self): instance = create_instance(Integer()) instance.attr = int(123) assert 123 == instance.attr
def test_default_handling(self): instance = create_instance(Integer(default=1234)) assert 1234 == instance.attr