Skip to content

Commit

Permalink
Merge pull request #207 from MyrikLD/fix_none_type
Browse files Browse the repository at this point in the history
Fix NoneType bug
  • Loading branch information
seperman authored Jul 23, 2020
2 parents fdb1062 + 567293b commit ab93181
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
4 changes: 3 additions & 1 deletion deepdiff/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,9 @@ def type_in_type_group(item, type_group):


def type_is_subclass_of_type_group(item, type_group):
return isinstance(item, type_group) or issubclass(item, type_group) or type_in_type_group(item, type_group)
return isinstance(item, type_group) \
or (isinstance(item, type) and issubclass(item, type_group)) \
or type_in_type_group(item, type_group)


def get_doc(doc_filename):
Expand Down
27 changes: 27 additions & 0 deletions tests/test_diff_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,33 @@ class ClassB:
result = {'attribute_removed': ['root.y']}
assert result == ddiff

def test_custom_class_changes_none_when_ignore_type(self):
ddiff = DeepDiff({'a': None}, {'a': 1}, ignore_type_subclasses=True, ignore_type_in_groups=[(int, float)])
result = {
'type_changes': {
"root['a']": {
'old_type': type(None),
'new_type': int,
'old_value': None,
'new_value': 1
}
}
}
assert result == ddiff

ddiff = DeepDiff({'a': 1}, {'a': None}, ignore_type_subclasses=True, ignore_type_in_groups=[(int, float)])
result = {
'type_changes': {
"root['a']": {
'old_type': int,
'new_type': type(None),
'old_value': 1,
'new_value': None
}
}
}
assert result == ddiff

def test_custom_object_changes_when_ignore_type_in_groups(self):
class ClassA:
def __init__(self, x, y):
Expand Down

0 comments on commit ab93181

Please sign in to comment.