Skip to content

Commit 3206a73

Browse files
committed
Fix broken test for Python 2.x
Fun fact: for Python 3.x you don't need to explicitly implement __ne__ method if __eq__ exists, but you have do this for 2.x or your objects may be equal and non-equal at the same time. Seems like, before refactoring, operator.eq had used right logic.
1 parent 89caf55 commit 3206a73

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

jsonpatch.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,9 @@ def __eq__(self, other):
248248
return False
249249
return True
250250

251+
def __ne__(self, other):
252+
return not(self == other)
253+
251254
@classmethod
252255
def from_string(cls, patch_str):
253256
"""Creates JsonPatch instance from string source.
@@ -391,6 +394,9 @@ def __eq__(self, other):
391394
return False
392395
return self.operation == other.operation
393396

397+
def __ne__(self, other):
398+
return not(self == other)
399+
394400

395401
class RemoveOperation(PatchOperation):
396402
"""Removes an object property or an array element."""

0 commit comments

Comments
 (0)