Skip to content

Commit 9f3bf65

Browse files
Fix integer parameters handling
1 parent 27e7d01 commit 9f3bf65

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

cloudinary_cli/utils/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ def parse_option_value(value):
8080
value = json.loads(value)
8181
except Exception:
8282
pass
83-
if isinstance(value, int):
83+
# serialize 0 to "0" string, otherwise it will be omitted (counted as False)
84+
if isinstance(value, int) and not value:
8485
value = str(value)
8586
return value
8687

test/test_utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ def test_parse_option_value(self):
1717
"a", "list"], parse_option_value('["this","will","be","read","as","a","list"]'))
1818

1919
def test_parse_option_value_converts_int_to_str(self):
20-
""" should convert a parsed int to a str """
21-
self.assertEqual("1", parse_option_value(1))
20+
""" should convert a parsed 0 to a str """
21+
self.assertEqual("0", parse_option_value(0))
22+
self.assertEqual(1, parse_option_value(1))
2223

2324
def test_parse_args_kwargs(self):
2425
args, kwargs = parse_args_kwargs(_no_args_test_func, [])

0 commit comments

Comments
 (0)