Commit e546b8e
committed
tools.memories, test: codify
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.SopelIdentifierMemory == dict behavior1 parent 86ac703 commit e546b8e
2 files changed
+42
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
440 | 440 | | |
441 | 441 | | |
442 | 442 | | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
0 commit comments