Пример #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