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