gh-145056: Let dict specific tests accept frozendict as well#145060
gh-145056: Let dict specific tests accept frozendict as well#145060rhettinger wants to merge 3 commits intopython:mainfrom
Conversation
serhiy-storchaka
left a comment
There was a problem hiding this comment.
This is not ready yet.
| d |= list(b.items()) | ||
| expected = OrderedDict({0: 0, 1: 1, 2: 2, 3: 3}) | ||
| self.assertEqual(a | dict(b), expected) | ||
| self.assertEqual(a | frozendict(b), expected) |
There was a problem hiding this comment.
Should not the type of the result to be tested too?
There was a problem hiding this comment.
The existing test didn't check result type. I don't want to feature creep this edit. Reviewing and expanding the existing test strategies can be a task for another day.
|
|
||
| def __or__(self, other): | ||
| if not isinstance(other, dict): | ||
| if not isinstance(other, (dict, frozendict)): |
There was a problem hiding this comment.
What about the C implementation?
There was a problem hiding this comment.
The C version already supported any mapping input, that is how the tests passed. But I will update the fast path to use PyAnyDict_CheckExact(arg).
| if isinstance(other, UserDict): | ||
| return self.__class__(self.data | other.data) | ||
| if isinstance(other, dict): | ||
| if isinstance(other, (dict, frozendict)): |
There was a problem hiding this comment.
No, I didn't see where the dict version was tested so left this alone.
|
When you're done making the requested changes, leave the comment: |
Fix the
dictspecific tests in thecollectionsmodule.