示例#1
0
    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
示例#2
0
    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
示例#3
0
    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
示例#4
0
 def test_numeric_string_disallowed(self):
     instance = create_instance(Integer())
     with self.assertRaises(TypeError):
         instance.attr = '123'
示例#5
0
 def test_float_disallowed(self):
     instance = create_instance(Integer())
     with self.assertRaises(TypeError):
         instance.attr = 123.0
示例#6
0
 def test_long_allowed(self):
     instance = create_instance(Integer())
     instance.attr = long(123)
     self.assertEqual(123, instance.attr)
示例#7
0
 def test_default_handling(self):
     instance = create_instance(Integer(default=1234))
     self.assertEqual(1234, instance.attr)
示例#8
0
 def test_int_allowed(self):
     instance = create_instance(Integer())
     instance.attr = int(123)
     assert 123 == instance.attr
示例#9
0
 def test_default_handling(self):
     instance = create_instance(Integer(default=1234))
     assert 1234 == instance.attr