Repository navigation
Dictionaries Should Be Equal added support for ignoring keys - #3942
Conversation
…ld Be Equal" added acceptance tests
Codecov Report
@@ Coverage Diff @@
## master #3942 +/- ##
==========================================
- Coverage 75.15% 75.11% -0.04%
==========================================
Files 222 222
Lines 18816 18816
Branches 3076 3076
==========================================
- Hits 14140 14131 -9
- Misses 4147 4153 +6
- Partials 529 532 +3
Continue to review full report at Codecov.
|
Dictionaries Should Be Equal added support for ignoring keys
pekkaklarck
left a comment
There was a problem hiding this comment.
First of all, sorry for a very late review. I had missed this PR earlier and now noticed it when finalizing RF 6.1. This looks so good that I'll merge it and fix the small issues mentioned in separate comments.
I also plan to change this so that the list of ignored keys can be given as a Python list literal. That would be easiest to implement by having list as a type hint for ignore_keys, but because this library doesn't use type hints otherwise (it should!) I'll probably implement it using ast.literal_eval separately.
| need to be same. | ||
|
|
||
| ``ignore_keys`` can be used to provide a list of keys to ignore in the | ||
| comparison. |
There was a problem hiding this comment.
Need a note when this option has been added.
| self._validate_dictionary(dict1) | ||
| self._validate_dictionary(dict2, 2) | ||
| dict1 = {k: v for k, v in dict1.items() if k not in ignore_keys} | ||
| dict2 = {k: v for k, v in dict2.items() if k not in ignore_keys} |
There was a problem hiding this comment.
This should be done only when ignore_keys is set. Now dictionaries are always recreated which wastes resources and in with custom dict subsclasses can also change semantics.
| See `Lists Should Be Equal` for more information about configuring | ||
| the error message with ``msg`` and ``values`` arguments. | ||
| """ | ||
|
|
There was a problem hiding this comment.
We don't generally use empty lines inside functions or methods.
|
No problem. Thanks for the feedback! |
Issue #2717
Added additional optional parameter to provide a list of keys to ignore in the comparison