Skip to content

Commit 1c71179

Browse files
authored
Merge pull request #202 from d0b3rm4n/fix-for-issue-200
Do not apply format to non numbers
2 parents 2f15fd2 + 71a54e3 commit 1c71179

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

deepdiff/helper.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,8 @@ def number_to_string(number, significant_digits, number_format_notation="f"):
340340
with localcontext() as ctx:
341341
ctx.prec = len(tup.digits) + tup.exponent + significant_digits
342342
number = number.quantize(Decimal('0.' + '0' * significant_digits))
343+
elif not isinstance(number, numbers):
344+
return number
343345
result = (using % significant_digits).format(number)
344346
# Special case for 0: "-0.00" should compare equal to "0.00"
345347
if set(result) <= ZERO_DECIMAL_CHARACTERS:

tests/test_diff_other.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,15 @@ def test_path_cache(self):
8080
path1 = diff['values_changed'][0].path()
8181
path2 = diff['values_changed'][0].path()
8282
assert 'root[0]' == path1 == path2
83+
84+
def test_bool_str(self):
85+
t1 = {'key1': True}
86+
t2 = {'key1': 'Yes'}
87+
diff = DeepDiff(t1, t2, ignore_type_in_groups=[(bool, str)],
88+
ignore_numeric_type_changes=True)
89+
expected = {'values_changed':
90+
{"root['key1']":
91+
{'new_value': 'Yes', 'old_value': True}
92+
}
93+
}
94+
assert diff == expected

0 commit comments

Comments
 (0)