trivial: assert non_negative_int treats float as valid
Prior to the Related-Change, non_negative_int would raise a ValueError if it was passed a positive float. It now casts the float to an int, which is consistent with the docstring. This patch adds test assertions to verify this behavior, and similar behavior of config_positive_int_value. Change-Id: I5d62e14c228544af634190f16321ee97a8c4211c Related-Change: I06508279d59fa57296dd85548f271a7812aeb45f
This commit is contained in:
1 changed files with 2 additions and 0 deletions
@@ -77,6 +77,7 @@ class TestUtilsConfig(unittest.TestCase):
self.assertEqual(0, config.non_negative_int('0'))
self.assertEqual(0, config.non_negative_int(0.0))
self.assertEqual(1, config.non_negative_int(1))
self.assertEqual(1, config.non_negative_int(1.1))
self.assertEqual(1, config.non_negative_int('1'))
self.assertEqual(1, config.non_negative_int(True))
self.assertEqual(0, config.non_negative_int(False))
@@ -118,6 +119,7 @@ class TestUtilsConfig(unittest.TestCase):
u'1': 1,
b'1': 1,
1: 1,
1.1: 1,
u'2': 2,
b'2': 2,
u'1024': 1024,
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.