obj,
quiet=False)
- def test_is_int_like(self):
- self.assertTrue(utils.is_int_like(1))
- self.assertTrue(utils.is_int_like(-1))
- self.assertTrue(utils.is_int_like(0b1))
- self.assertTrue(utils.is_int_like(0o1))
- self.assertTrue(utils.is_int_like(0x1))
- self.assertTrue(utils.is_int_like('1'))
- self.assertFalse(utils.is_int_like(1.0))
- self.assertFalse(utils.is_int_like('abc'))
-
def test_check_exclusive_options(self):
utils.check_exclusive_options()
utils.check_exclusive_options(something=None,
return obj
-def is_int_like(val):
- """Check if a value looks like an int."""
- try:
- return str(int(val)) == str(val)
- except Exception:
- return False
-
-
def check_exclusive_options(**kwargs):
"""Checks that only one of the provided options is actually not-none.
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import excutils
+from oslo_utils import strutils
from oslo_utils import timeutils
from oslo_utils import uuidutils
import six
# of the size value. BUT there is a possibility that somebody
# could call the API directly so the is_int_like check
# handles both cases (string representation of true float or int).
- if size and (not utils.is_int_like(size) or int(size) <= 0):
+ if size and (not strutils.is_int_like(size) or int(size) <= 0):
msg = _('Invalid volume size provided for create request: %s '
'(size argument must be an integer (or string '
'representation of an integer) and greater '