Skip to content

Commit

Permalink
Merge pull request #182 from nathanielobrown/master
Browse files Browse the repository at this point in the history
Adds support for datetime.time objects per issue#181
  • Loading branch information
seperman committed Mar 26, 2020
2 parents 85d007f + ecac906 commit f618c9d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion deepdiff/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
strings = (str, bytes) # which are both basestring
unicode_type = str
bytes_type = bytes
numbers = (int, float, complex, datetime.datetime, datetime.date, datetime.timedelta, Decimal)
numbers = (int, float, complex, datetime.datetime, datetime.date, datetime.timedelta, Decimal, datetime.time)

IndexedHash = namedtuple('IndexedHash', 'indexes item')

Expand Down
15 changes: 15 additions & 0 deletions tests/test_diff_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,21 @@ def test_diffs_timedeltas(self):
result = {}
assert result == ddiff

def test_diffs_times(self):
t1 = datetime.time(1, 1)
t2 = datetime.time(1, 2)
t3 = datetime.time(1, 1)
expected_result = {
'values_changed': {
'root': {
'new_value': t2,
'old_value': t1
}
}
}
assert DeepDiff(t1, t2) == expected_result
assert DeepDiff(t1, t3) == {}

def test_string_difference(self):
t1 = {1: 1, 2: 2, 3: 3, 4: {"a": "hello", "b": "world"}}
t2 = {1: 1, 2: 4, 3: 3, 4: {"a": "hello", "b": "world!"}}
Expand Down

0 comments on commit f618c9d

Please sign in to comment.