Browse Source

Better check for integer range to account for 0

We should be using "if value is not None" to better check
for the condition where the value is 0 and 0 is not in the
valid range.

Co-Authored-By: Longjie_Cao <grasson1101@aliyun.com>
Closes-Bug: #1416212
Change-Id: Ie5c81f1916e301619955364b040bdc7a9275e29c
changes/40/151940/2
Davanum Srinivas 7 years ago
parent
commit
0366f880d5
  1. 1
      oslo_config/tests/test_types.py
  2. 2
      oslo_config/types.py

1
oslo_config/tests/test_types.py

@ -208,6 +208,7 @@ class IntegerTypeTests(TypeTestHelper, unittest.TestCase):
t(123)
t(300)
t(456)
self.assertRaises(ValueError, t, 0)
self.assertRaises(ValueError, t, 457)

2
oslo_config/types.py

@ -144,7 +144,7 @@ class Integer(ConfigType):
else:
value = int(value)
if value:
if value is not None:
self._check_range(value)
return value

Loading…
Cancel
Save