Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tools.memories, test: codify
SopelIdentifierMemory == dict
behavior
Comparing two `SopelIdentifierMemory` instances using `==` already worked, but if one side of the comparison was a plain `dict` it would be almost impossible for the two to be considered equal. It's obviously doable to override `__eq__()`/`__ne__()` and make the two types test as equal if they have equal values associated with keys-that- are-equivalent-when-compared-as-`Identifier`s, but we probably shouldn't do that. I'm perfectly happy to consider objects of different types as "not equal" even if they contain equivalent key-value pairs. Therefore, these new tests codify the `==`/`!=` behavior as follows: * `SopelIdentifierMemory` objects will compare as equal if their keys and values compare as equal, even if they use different `IdentifierFactory` (the `make_identifier` parameter) implementations. * A `SopelIdentifierMemory` and a `dict[Identifier]` MAY compare as equal if the `Identifier` keys in each were created by compatible (but not necessarily identical) `IdentifierFactory` implementations. * A `SopelIdentifierMemory` and a `dict[str]` (or any other `dict` with non-`Identifier` keys) are not expected to compare as equal.
- Loading branch information