Commit cf8d95be authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

TEST: Test that property can be set to None, unless required=True

parent 6b7a127f
...@@ -15,6 +15,7 @@ def test_Int(): ...@@ -15,6 +15,7 @@ def test_Int():
class MyObj(props.HasProperties): class MyObj(props.HasProperties):
unbounded = props.Int() unbounded = props.Int()
required = props.Int(required=True, allowInvalid=False)
unbounded_default = props.Int(default=10) unbounded_default = props.Int(default=10)
bounded = props.Int(minval=0, maxval=10) bounded = props.Int(minval=0, maxval=10)
bounded_min = props.Int(minval=0) bounded_min = props.Int(minval=0)
...@@ -26,14 +27,17 @@ def test_Int(): ...@@ -26,14 +27,17 @@ def test_Int():
obj = MyObj() obj = MyObj()
# property, value, expected
assert obj.unbounded_default == 10 assert obj.unbounded_default == 10
with pytest.raises(ValueError): obj.unbounded = '' with pytest.raises(ValueError): obj.unbounded = ''
with pytest.raises(ValueError): obj.unbounded = 'abcde' with pytest.raises(ValueError): obj.unbounded = 'abcde'
with pytest.raises(TypeError): obj.unbounded = None with pytest.raises(ValueError): obj.required = None
obj.unbounded = None
obj.required = 10
# property, value, expected
testcases = [ testcases = [
('unbounded', '-999', -999), ('unbounded', '-999', -999),
('unbounded', '0', 0), ('unbounded', '0', 0),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment