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 — Preserve insertion order for extra dict items in assertion output by RafiB982 · Pull Request #14066 · pytest-dev/pytest ConversationWhen dict assertions fail, pytest currently displays extra items using This change preserves insertion order for the A focused regression test is included. Closes #13503
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
RafiB982
marked this pull request as ready for review
nicoddemus
requested changes
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @RafiB982, please take a look at my comments.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is more efficient to reuse the set for the containment check:
Suggested change
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please let's use a dict with more keys for this test, only 2 seems few to catch any regressions. I suggest using simply
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Comment on lines
+2221
to
+2235
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we use just
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
nicoddemus
requested changes
Comment on lines
+2203
to
+2229
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def test_dict_extra_items_preserve_insertion_order(pytester): | |
| pytester.makepyfile( | |
| test_order=""" | |
| def test_order(): | |
| a = { | |
| "b": 2, | |
| "a": 1, | |
| "d": 4, | |
| "e": 5, | |
| "c": 3, | |
| } | |
| assert a == {} | |
| """ | |
| ) | |
| result = pytester.runpytest("-vv") | |
| result.stdout.fnmatch_lines( | |
| [ | |
| "*Left contains 5 more items:*", | |
| "*'b': 2*", | |
| "*'a': 1*", | |
| "*'d': 4*", | |
| "*'e': 5*", | |
| "*'c': 3*", | |
| ] | |
| ) | |
| def test_dict_extra_items_preserve_insertion_order(pytester: Pytester) -> None: | |
| """Assertion output of dict diff shows keys in insertion order (#13503).""" | |
| pytester.makepyfile( | |
| test_order=""" | |
| def test_order(): | |
| a = { | |
| "b": 2, | |
| "a": 1, | |
| "d": 4, | |
| "e": 5, | |
| "c": 3, | |
| } | |
| assert a == {} | |
| """ | |
| ) | |
| result = pytester.runpytest("-vv") | |
| result.stdout.fnmatch_lines( | |
| [ | |
| "*Left contains 5 more items:*", | |
| "*Full diff:", | |
| "* + *'b': 2,", | |
| "* + *'a': 1,", | |
| "* + *'d': 4,", | |
| "* + *'e': 5,", | |
| "* + *'c': 3,", | |
| "test_order.py:*: AssertionError", | |
| ] | |
| ) |
The test above fails in main and also fails in this branch. It seems more work is needed to handle the Full diff output.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| @@ -0,0 +1 @@ | |||
| Preserved insertion order for extra dictionary items in assertion failure output. | |||
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| Preserved insertion order for extra dictionary items in assertion failure output. | |
| Display dictionary differences in assertion failures using the original key insertion order instead of sorted order. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
The documentation failure is being addressed in #14067. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hi @nicoddemus ,
I’ve rebased the branch and pushed the changes. Please let me know if anything else should be adjusted. |
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.
I have not reviewed the changes in deep, but:
main removing those.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hi @nicoddemus , |
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.
Thanks @RafiB982
However I still see unrelated changes; please rebase and remove the extra commits.
Also, tests are still failing.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hello @nicoddemus , (pytest-venv) rafi@ENDEAVOUR:~/pytest$ git show diff --git a/src/_pytest/assertion/util.py b/src/_pytest/assertion/util.py
diff --git a/src/_pytest/assertion/util.py b/src/_pytest/assertion/util.py
+import re
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hi @nicoddemus , as suggested fixed all errors. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hi @nicoddemus, let me know if you are okay with PR.. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@RafiB982 not there yet, please see #14066 (comment). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Superseded by #14050, thanks anyway, appreciate the attempt. 👍 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Fixes #13503 Closes #14066 (cherry picked from commit 966edc9) Co-authored-by: DavidAG <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Failure output order of dictionary keys is alphabetical instead of insertion order
There was an error while loading. Please reload this page.