From d4918e17c555df1b46827f865c5c105097199f80 Mon Sep 17 00:00:00 2001 From: Seperman Date: Sun, 28 May 2017 22:38:54 -0700 Subject: [PATCH] Fixing #64. Bumping version to 3.2.1 --- README.md | 4 ++-- README.txt | 3 ++- deepdiff/contenthash.py | 9 ++++++--- deepdiff/diff.py | 4 +--- docs/conf.py | 4 ++-- docs/index.rst | 3 ++- setup.py | 2 +- tests/test_diff_text.py | 21 ++++++++++++++------- 8 files changed, 30 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 80b2d3a9..8f5b62f6 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ -# deepdiff v 3.2.0 +# deepdiff v 3.2.1 [![Join the chat at https://gitter.im/deepdiff/Lobby](https://badges.gitter.im/deepdiff/Lobby.svg)](https://gitter.im/deepdiff/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - ![Python Versions](https://img.shields.io/pypi/pyversions/deepdiff.svg?style=flat) ![Doc](https://readthedocs.org/projects/deepdiff/badge/?version=latest) @@ -795,6 +794,7 @@ And here is more info: ##Changelog +- v3-2-1: Fixing hash of None - v3-2-0: Adding grep for search: object | grep(item) - v3-1-3: Unicode vs. Bytes default fix - v3-1-2: NotPresent Fix when item is added or removed. diff --git a/README.txt b/README.txt index 5aea0293..d33f2935 100644 --- a/README.txt +++ b/README.txt @@ -1,4 +1,4 @@ -**DeepDiff v 3.2.0** +**DeepDiff v 3.2.1** Deep Difference of dictionaries, iterables, strings and other objects. It will recursively look for all the changes. @@ -240,6 +240,7 @@ http://zepworks.com/blog/diff-it-to-digg-it/ **Changelog** +- v3-2-1: Fixing hash of None - v3-2-0: Adding grep for search: object | grep(item) - v3-1-3: Unicode vs. Bytes default fix - v3-1-2: NotPresent Fix when item is added or removed. diff --git a/deepdiff/contenthash.py b/deepdiff/contenthash.py index 05fffa5b..501cb073 100644 --- a/deepdiff/contenthash.py +++ b/deepdiff/contenthash.py @@ -44,8 +44,6 @@ class DeepHash(dict): **DeepHash** """ - show_warning = True - def __init__(self, obj, hashes=None, @@ -76,7 +74,9 @@ def __init__(self, self.__hash(obj, parents_ids=frozenset({id(obj)})) - if not self['unprocessed']: + if self['unprocessed']: + logger.warning("Can not hash the following items: {}.".format(self['unprocessed'])) + else: del self['unprocessed'] @staticmethod @@ -233,6 +233,9 @@ def __hash(self, obj, parent="root", parents_ids=frozenset({})): if self.__skip_this(obj): result = self.skipped + elif obj is None: + result = 'NONE' + elif isinstance(obj, strings): result = self.__hash_str(obj) diff --git a/deepdiff/diff.py b/deepdiff/diff.py index 9baab785..c14e5b28 100644 --- a/deepdiff/diff.py +++ b/deepdiff/diff.py @@ -608,8 +608,6 @@ class DeepDiff(ResultDict): """ - show_warning = True - def __init__(self, t1, t2, @@ -901,7 +899,7 @@ def __diff_str(self, level): """Compare strings""" if level.t1 == level.t2: return - + # do we add a diff for convenience? do_diff = True if isinstance(level.t1, bytes_type): diff --git a/docs/conf.py b/docs/conf.py index e88fc014..cd9fb4f5 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -60,9 +60,9 @@ # built documents. # # The short X.Y version. -version = '3.2.0' +version = '3.2.1' # The full version, including alpha/beta/rc tags. -release = '3.2.0' +release = '3.2.1' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/index.rst b/docs/index.rst index 752de01d..269932a7 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -3,7 +3,7 @@ You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. -DeepDiff 3.2.0 documentation! +DeepDiff 3.2.1 documentation! ============================= **DeepDiff: Deep Difference of dictionaries, iterables and almost any other object recursively.** @@ -346,6 +346,7 @@ Indices and tables Changelog ========= +- v3-2-1: Fixing hash of None - v3-2-0: Adding grep for search: object | grep(item) - v3-1-3: Unicode vs. Bytes default fix - v3-1-2: NotPresent Fix when item is added or removed. diff --git a/setup.py b/setup.py index c696441d..d66b8189 100755 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ long_description = "Deep Difference and Search of any Python object/data." setup(name='deepdiff', - version='3.2.0', + version='3.2.1', description='Deep Difference and Search of any Python object/data.', url='https://github.com/seperman/deepdiff', download_url='https://github.com/seperman/deepdiff/tarball/master', diff --git a/tests/test_diff_text.py b/tests/test_diff_text.py index 92bead86..8b1a543b 100644 --- a/tests/test_diff_text.py +++ b/tests/test_diff_text.py @@ -23,7 +23,7 @@ import datetime from decimal import Decimal from deepdiff import DeepDiff -from deepdiff.helper import py3, bytes_type +from deepdiff.helper import py3 from tests import CustomClass if py3: from unittest import mock @@ -177,7 +177,7 @@ def test_string_difference2(self): } } self.assertEqual(ddiff, result) - + def test_bytes(self): t1 = { 1: 1, @@ -189,11 +189,11 @@ def test_bytes(self): "c": b"\x80", } } - t2 = {1: 1, - 2: 2, - 3: 3, + t2 = {1: 1, + 2: 2, + 3: 3, 4: { - "a": b"hello", + "a": b"hello", "b": b"world\n1\n2\nEnd", "c": b'\x81', } @@ -214,7 +214,7 @@ def test_bytes(self): } } self.assertEqual(ddiff, result) - + def test_unicode(self): t1 = { 1: 1, @@ -543,6 +543,13 @@ def test_list_of_sets_difference_ignore_order_when_there_is_duplicate_and_mix_of result = {'iterable_item_added': {'root[0]': {4}}} self.assertEqual(ddiff, result) + def test_set_of_none(self): + """ + https://github.com/seperman/deepdiff/issues/64 + """ + ddiff = DeepDiff(set(), set([None])) + self.assertEqual(ddiff, {'set_item_added': {'root[None]'}}) + def test_list_that_contains_dictionary(self): t1 = {1: 1, 2: 2, 3: 3, 4: {"a": "hello", "b": [1, 2, {1: 1, 2: 2}]}} t2 = {1: 1, 2: 2, 3: 3, 4: {"a": "hello", "b": [1, 2, {1: 3}]}}