Skip to content
Merged

Dev #165

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ matrix:
- python: 3.6
- python: pypy3
- python: 3.7
- python: 3.8
dist: xenial
sudo: true

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# DeepDiff v 4.0.8
# DeepDiff v 4.0.9

<!-- ![Downloads](https://img.shields.io/pypi/dm/deepdiff.svg?style=flat) -->
![Python Versions](https://img.shields.io/pypi/pyversions/deepdiff.svg?style=flat)
Expand Down Expand Up @@ -417,6 +417,7 @@ And then running

# ChangeLog

- v4-0-9: Fixing the bug for hashing custom unhashable objects
- v4-0-8: Adding ignore_nan_inequality for float('nan')
- v4-0-7: Hashing of the number 1 vs. True
- v4-0-6: found a tiny bug in Python formatting of numbers in scientific notation. Added a workaround.
Expand Down
2 changes: 1 addition & 1 deletion deepdiff/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""This module offers the DeepDiff, DeepSearch, grep and DeepHash classes."""
# flake8: noqa
__version__ = '4.0.8'
__version__ = '4.0.9'
import logging

if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion deepdiff/deephash.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def _hash(self, obj, parent, parents_ids=EMPTY_FROZENSET):
elif isinstance(obj, Iterable):
result = self._prep_iterable(obj=obj, parent=parent, parents_ids=parents_ids)

elif obj in {BoolObj.TRUE, BoolObj.FALSE}:
elif obj == BoolObj.TRUE or obj == BoolObj.FALSE:
result = 'bool:true' if obj is BoolObj.TRUE else 'bool:false'
else:
result = self._prep_obj(obj=obj, parent=parent, parents_ids=parents_ids)
Expand Down
6 changes: 3 additions & 3 deletions deepdiff/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,9 @@ def __create_hashtable(self, t, level):
)
item_hash = hashes_all[item]
except Exception as e: # pragma: no cover
logger.warning("Can not produce a hash for %s."
"Not counting this object.\n %s" %
(level.path(), e))
logger.error("Can not produce a hash for %s."
"Not counting this object.\n %s" %
(level.path(), e))
else:
if item_hash is unprocessed: # pragma: no cover
logger.warning("Item %s was not processed while hashing "
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@
# built documents.
#
# The short X.Y version.
version = '4.0.8'
version = '4.0.9'
# The full version, including alpha/beta/rc tags.
release = '4.0.8'
release = '4.0.9'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
3 changes: 2 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
contain the root `toctree` directive.


DeepDiff 4.0.8 documentation!
DeepDiff 4.0.9 documentation!
=============================

**DeepDiff: Deep Difference of dictionaries, iterables, strings and other objects. It will recursively look for all the changes.**
Expand Down Expand Up @@ -281,6 +281,7 @@ Indices and tables
Changelog
=========

- v4-0-9: Fixing the bug for hashing custom unhashable objects
- v4-0-8: Adding ignore_nan_inequality for float('nan')
- v4-0-7: Hashing of the number 1 vs. True
- v4-0-6: found a tiny bug in Python formatting of numbers in scientific notation. Added a workaround.
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 4.0.8
current_version = 4.0.9
commit = True
tag = True
tag_name = {new_version}
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
if os.environ.get('USER', '') == 'vagrant':
del os.link

version = '4.0.8'
version = '4.0.9'


def get_reqs(filename):
Expand Down
9 changes: 9 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,12 @@ def __repr__(self):
class CustomClassMisleadingRepr(CustomClass):
def __str__(self):
return "({}, {})".format(self.a, self.b)


class CustomClass2:
def __init__(self, prop1=None, prop2=None):
self.prop1 = prop1 or []
self.prop2 = prop2 or []

def __eq__(self, other):
return self.__dict__ == other.__dict__
17 changes: 15 additions & 2 deletions tests/test_diff_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from deepdiff import DeepDiff
from deepdiff.helper import number_to_string
from deepdiff.helper import pypy3
from tests import CustomClass
from tests import CustomClass, CustomClass2

logging.disable(logging.CRITICAL)

Expand Down Expand Up @@ -858,6 +858,19 @@ def test_custom_objects_change(self):
}
assert result == ddiff

def test_custom_objects2(self):
cc_a = CustomClass2(prop1=["a"], prop2=["b"])
cc_b = CustomClass2(prop1=["b"], prop2=["b"])
t1 = [cc_a, CustomClass2(prop1=["c"], prop2=["d"])]
t2 = [cc_b, CustomClass2(prop1=["c"], prop2=["d"])]

ddiff = DeepDiff(t1, t2, ignore_order=True)

result = {'iterable_item_added': {'root[0]': cc_b},
'iterable_item_removed': {'root[0]': cc_a}}

assert result == ddiff

def test_custom_objects_slot_change(self):
class ClassA:
__slots__ = ('x', 'y')
Expand Down Expand Up @@ -1701,7 +1714,7 @@ def test_diff_when_hash_fails(self, mock_DeepHash, mock_logger):
t1 = {"blah": {4}, 2: 1337}
t2 = {"blah": {4}, 2: 1337}
DeepDiff(t1, t2, ignore_order=True)
assert mock_logger.warning.called
assert mock_logger.error.called

def test_bool_vs_number(self):
t1 = {
Expand Down