Skip to content

Commit

Permalink
Minor fix to misc_utils.to_integer to handle float string.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmichaels-harvard committed Dec 12, 2023
1 parent bec0884 commit 2c15cec
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion test/test_misc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
ObsoleteError, CycleError, TopologicalSorter, keys_and_values_to_dict, dict_to_keys_and_values, is_c4_arn,
deduplicate_list, chunked, parse_in_radix, format_in_radix, managed_property, future_datetime,
MIN_DATETIME, MIN_DATETIME_UTC, INPUT, builtin_print, map_chunked, to_camel_case, json_file_contents,
pad_to, JsonLinesReader, split_string, merge_objects
pad_to, JsonLinesReader, split_string, merge_objects, to_integer
)
from dcicutils.qa_utils import (
Occasionally, ControlledTime, override_environ as qa_override_environ, MockFileSystem, printed_output,
Expand Down Expand Up @@ -3674,3 +3674,14 @@ def test_merge_objects_8():
"xyzzy": [{"foo": None}, {"goo": None}, {"hoo": None}, {"hoo": None}, {"hoo": None}]}
merge_objects(target, source, True)
assert target == expected


def test_to_integer():
assert to_integer("17") == 17
assert to_integer("17.0") == 17
assert to_integer("17.1") == 17
assert to_integer("17.9", "123") == 17
assert to_integer("0") == 0
assert to_integer("0.0") == 0
assert to_integer("asdf") is None
assert to_integer("asdf", "myfallback") == "myfallback"

0 comments on commit 2c15cec

Please sign in to comment.