GeezerVison is showing github.com — updating changelog · sreecodeslayer/deepdiff@6e5a87f
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: README.md +10Lines changed: 10 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -281,6 +281,15 @@ Approximate float comparison: | 281 | 281 | {'values_changed': {'root': {'new_value': 1.24e+20, 'old_value': 1.23e+20}}} | 282 | 282 | ``` | 283 | 283 |
| | 284 | +### Using DeepDiff in unit tests | | 285 | + | | 286 | +`result` is the output of the function that is being tests. | | 287 | +`expected` is the expected output of the function. | | 288 | + | | 289 | +```python | | 290 | +assertEqual(DeepDiff(result, expected), {}) | | 291 | +``` | | 292 | + | 284 | 293 | ## Difference with Json Patch | 285 | 294 |
| 286 | 295 | Unlike [Json Patch](https://tools.ietf.org/html/rfc6902) which is designed only for Json objects, DeepDiff is designed specifically for almost all Python types. In addition to that, DeepDiff checks for type changes and attribute value changes that Json Patch does not cover since there are no such things in Json. Last but not least, DeepDiff gives you the exact path of the item(s) that were changed in Python syntax. | @@ -305,6 +314,7 @@ Example in DeepDiff for the same operation: | 305 | 314 |
| 306 | 315 | ##Changelog | 307 | 316 |
| | 317 | +- v1-6-0: Unifying key names. i.e newvalue is new_value now. For backward compatibility, newvalue still works. | 308 | 318 | - v1-5-0: Fixing ignore order containers with unordered items. Adding significant digits when comparing decimals. Changes property is deprecated. | 309 | 319 | - v1-1-0: Changing Set, Dictionary and Object Attribute Add/Removal to be reported as Set instead of List. Adding Pypy compatibility. | 310 | 320 | - v1-0-2: Checking for ImmutableMapping type instead of dict | |
Collapse file Copy file name to clipboardExpand all lines: README.txt +9Lines changed: 9 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -185,6 +185,14 @@ Object attribute added: | 185 | 185 | 'values_changed': {'root.b': {'new_value': 2, 'old_value': 1}}} | 186 | 186 |
| 187 | 187 |
| | 188 | +Using DeepDiff in unit tests | | 189 | +result is the output of the function that is being tests. | | 190 | +expected is the expected output of the function. | | 191 | + >>> assertEqual(DeepDiff(result, expected), {}) | | 192 | + | | 193 | + | | 194 | + | | 195 | + | 188 | 196 | **Difference with Json Patch** | 189 | 197 |
| 190 | 198 | Unlike Json Patch https://tools.ietf.org/html/rfc6902 which is designed only for Json objects, DeepDiff is designed specifically for almost all Python types. In addition to that, DeepDiff checks for type changes and attribute value changes that Json Patch does not cover since there are no such things in Json. Last but not least, DeepDiff gives you the exact path of the item(s) that were changed in Python syntax. | @@ -201,6 +209,7 @@ Example in DeepDiff for the same operation: | 201 | 209 |
| 202 | 210 | **Changelog** | 203 | 211 |
| | 212 | +- v1-6-0: Unifying key names. i.e newvalue is new_value now. For backward compatibility, newvalue still works. | 204 | 213 | - v1-5-0: Fixing ignore order containers with unordered items. Adding significant digits when comparing decimals. Changes property is deprecated. | 205 | 214 | - v1-1-0: Changing Set, Dictionary and Object Attribute Add/Removal to be reported as Set instead of List. Adding Pypy compatibility. | 206 | 215 | - v1-0-2: Checking for ImmutableMapping type instead of dict | |
Collapse file Copy file name to clipboardExpand all lines: deepdiff/deepdiff.py +11Lines changed: 11 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 5 | 5 | import sys | 6 | 6 | import difflib | 7 | 7 | import datetime | | 8 | +import logging | 8 | 9 | try: | 9 | 10 | import cPickle as pickle | 10 | 11 | except: | | 34 | 35 | from itertools import izip_longest as zip_longest | 35 | 36 | items = 'iteritems' | 36 | 37 |
| | 38 | +logging.basicConfig(format='%(asctime)s %(levelname)8s %(message)s') | | 39 | +logger = logging.getLogger() | | 40 | + | 37 | 41 | IndexedHash = namedtuple('IndexedHash', 'indexes item') | 38 | 42 |
| 39 | 43 | EXPANDED_KEY_MAP = { | @@ -85,9 +89,14 @@ class RemapDict(dict): | 85 | 89 | For keys that have a new, longer name, remap the old key to the new key. | 86 | 90 | Other keys that don't have a new name are handled as before. | 87 | 91 | """ | | 92 | + show_warning = True | 88 | 93 |
| 89 | 94 | def __getitem__(self, old_key): | 90 | 95 | new_key = EXPANDED_KEY_MAP.get(old_key, old_key) | | 96 | + if self.show_warning and new_key != old_key: | | 97 | + self.show_warning = False | | 98 | + logger.warning("DeepDiff Deprecation: %s is renamed to %s. Please start using\ | | 99 | + the new unified naming convention.", old_key, new_key) | 91 | 100 | if new_key in self: | 92 | 101 | return self.get(new_key) | 93 | 102 | else: | @@ -337,6 +346,8 @@ class DeepDiff(RemapDict): | 337 | 346 | {'values_changed': {'root': {'new_value': 1.24e+20, 'old_value': 1.23e+20}}} | 338 | 347 | """ | 339 | 348 |
| | 349 | + show_warning = True | | 350 | + | 340 | 351 | def __init__(self, t1, t2, ignore_order=False, report_repetition=False, significant_digits=None, **kwargs): | 341 | 352 | if kwargs: | 342 | 353 | raise ValueError("The following parameter(s) are not valid: %s\nThe valid parameters are ignore_order, report_repetition and significant_digits" % ', '.join(kwargs.keys())) | |
Collapse file Copy file name to clipboardExpand all lines: docs/index.rst +1Lines changed: 1 addition & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -44,6 +44,7 @@ Indices and tables | 44 | 44 | Changelog | 45 | 45 | ========= | 46 | 46 |
| | 47 | +- v1-6-0: Unifying key names. i.e newvalue is new_value now. For backward compatibility, newvalue still works. | 47 | 48 | - v1-5-0: Fixing ignore order containers with unordered items. Adding significant digits when comparing decimals. Changes property is deprecated. | 48 | 49 | - v1-1-0: Changing Set, Dictionary and Object Attribute Add/Removal to be reported as Set instead of List. Adding Pypy compatibility. | 49 | 50 | - v1-0-2: Checking for ImmutableMapping type instead of dict | |
Collapse file Copy file name to clipboardExpand all lines: tests.py +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 12 | 12 | from decimal import Decimal | 13 | 13 | from deepdiff import DeepDiff | 14 | 14 | from sys import version | | 15 | +import logging | | 16 | +logging.disable(logging.CRITICAL) | 15 | 17 |
| 16 | 18 | py3 = version[0] == '3' | 17 | 19 |
| |
|