ReactiveX / RxPY

ReactiveX for Python
https://rxpy.rtfd.io
MIT License
4.81k stars 361 forks source link

[TESTING] Notification equality uses string representation #691

Closed matiboy closed 1 year ago

matiboy commented 1 year ago

Describe the bug The test for equality of Notifications in tests uses str equality instead of equality leading to false negatives

To Reproduce

ReactiveTest.on_next(300, Decimal(0)) == ReactiveTest.on_next(300, Decimal("0.0")) # false even though Decimal(0) == Decimal("0.0") is true
ReactiveTest.on_next(300, {"a": 42, "b": 5}) == ReactiveTest.on_next(300, 
 {"b": 5, "a": 42}) # false though {"a": 42, "b": 5} == {"b": 5, "a": 42} is True

Expected behavior Above examples should be equal

Code or Screenshots This is caused by using string inside class Notification(Generic[_T]):

def equals(self, other: "Notification[_T]") -> bool:
        """Indicates whether this instance and a specified object are
        equal."""

        other_string = "" if not other else str(other)
        return str(self) == other_string
matiboy commented 1 year ago

Just realized that this is a duplicate of #599

@dbrattli Are we still looking for a PR to fix this? I can give it a go...

Also, closing the issue as duplicate

matiboy commented 1 year ago

Duplicate of #599