-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
bpo-37212: Preserve keyword argument order in unittest.mock.call and error messages #14310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
dhilst
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
ammaraskar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, preserving the call order is far more intuitive.
And for reference this is just a visual change useful for users introspecting test failures and such,
>>> m = Mock()
>>> m(b=1, a=2)
>>> m.assert_called_with(a=2, b=1)works and will continue to work.
|
Thanks @tirkarthi for the PR, and @zware for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8. |
…error messages (pythonGH-14310) (cherry picked from commit 9d60706) Co-authored-by: Xtreak <tir.karthi@gmail.com>
|
GH-15755 is a backport of this pull request to the 3.8 branch. |
|
Thanks for the patch, @tirkarthi, and for the reviews @dhilst and @ammaraskar! Due to the (admittedly very slim) chance that this could break things for someone who shouldn't be relying on repr orders anyway, I won't backport this further than 3.8. |
Since Python 3.6 the order of keyword arguments is preserved. Change
mock.callrepr and error messages to print the original order instead of sorting it.https://bugs.python.org/issue37212