Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
FSL
fsleyes
fsleyes-props
Commits
cf8d95be
Commit
cf8d95be
authored
Mar 27, 2021
by
Paul McCarthy
🚵
Browse files
TEST: Test that property can be set to None, unless required=True
parent
6b7a127f
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/test_property_number.py
View file @
cf8d95be
...
...
@@ -15,6 +15,7 @@ def test_Int():
class
MyObj
(
props
.
HasProperties
):
unbounded
=
props
.
Int
()
required
=
props
.
Int
(
required
=
True
,
allowInvalid
=
False
)
unbounded_default
=
props
.
Int
(
default
=
10
)
bounded
=
props
.
Int
(
minval
=
0
,
maxval
=
10
)
bounded_min
=
props
.
Int
(
minval
=
0
)
...
...
@@ -26,14 +27,17 @@ def test_Int():
obj
=
MyObj
()
# property, value, expected
assert
obj
.
unbounded_default
==
10
with
pytest
.
raises
(
ValueError
):
obj
.
unbounded
=
''
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
=
[
(
'unbounded'
,
'-999'
,
-
999
),
(
'unbounded'
,
'0'
,
0
),
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment