GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-145056: Let dict specific tests accept frozendict as well by rhettinger · Pull Request #145060 · python/cpython Conversation
|
| 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.
The reason will be displayed to describe this comment to others. Learn more.
Should not the type of the result to be tested too?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
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.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The new tests are passed with unmodified code. Therefore they are not correct tests for this change.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| def __or__(self, other): | ||
| if not isinstance(other, dict): | ||
| if not isinstance(other, (dict, frozendict)): |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
What about the C implementation?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
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).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| 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.
The reason will be displayed to describe this comment to others. Learn more.
Any tests for this?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
No, I didn't see where the dict version was tested so left this alone.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Very bad. We need to add tests with dict first.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Well, let's leave this. There are many other missing tests for UserDict and UserList. I am working on this.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
#145145 will add new tests. Now there will be a place for new frozendict tests.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
When you're done making the requested changes, leave the comment: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| 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.
The reason will be displayed to describe this comment to others. Learn more.
The new tests are passed with unmodified code. Therefore they are not correct tests for this change.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| 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.
The reason will be displayed to describe this comment to others. Learn more.
Very bad. We need to add tests with dict first.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.