Skip to content
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

Tkinter: Tk 8.7 alphabetizes options in certain error messages #104497

Closed
Tracked by #104568
chrstphrchvz opened this issue May 15, 2023 · 5 comments
Closed
Tracked by #104568

Tkinter: Tk 8.7 alphabetizes options in certain error messages #104497

chrstphrchvz opened this issue May 15, 2023 · 5 comments
Labels
tests Tests in the Lib/test dir topic-tkinter type-bug An unexpected behavior, bug, or error

Comments

@chrstphrchvz
Copy link
Contributor

chrstphrchvz commented May 15, 2023

As done by e.g. https://core.tcl-lang.org/tk/info/b7db31b3a38b and causing this Tkinter test to fail:

======================================================================
FAIL: test_configure_type (test.test_tkinter.test_widgets.MenuTest.test_configure_type)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/user/git/cpython/Lib/test/test_tkinter/test_widgets.py", line 1403, in test_configure_type
    self.checkEnumParam(
  File "/Users/user/git/cpython/Lib/test/test_tkinter/widget_tests.py", line 134, in checkEnumParam
    self.checkInvalidParam(widget, name, 'spam', errmsg=errmsg)
  File "/Users/user/git/cpython/Lib/test/test_tkinter/widget_tests.py", line 63, in checkInvalidParam
    self.assertEqual(str(cm.exception), errmsg)
AssertionError: 'bad type "spam": must be menubar, normal, or tearoff' != 'bad type "spam": must be normal, tearoff, or menubar'
- bad type "spam": must be menubar, normal, or tearoff
+ bad type "spam": must be normal, tearoff, or menubar

Linked PRs

@sunmy2019 sunmy2019 added type-bug An unexpected behavior, bug, or error tests Tests in the Lib/test dir topic-tkinter labels May 15, 2023
@terryjreedy
Copy link
Member

Easy fix would be to change errmsg = ... to errprefix = 'bad type "spam": must be ' and add [:25] to str(...). I am keeping equality check instead of using .startswith to for helpful error message.

@sunmy2019
Copy link
Member

And if you want a little more, you can use

>>> from collections import Counter
>>> Counter("1234") == Counter("3412")
True

@terryjreedy
Copy link
Member

@sunmy2019 As near as I can tell from from searching _tkinter.c and tkinter/init.py, the actual error message is from tcl/tk. If so, all that needs testing is that as error is raised with 'spam' in the message. The options in the expected message come from the test itself, so a mismatch would indicate an error in tcl/tk, which we are not trying to test, or in the test, from being overy specific.

@chrstphrchvz The title and linked tcl issue suggest that multiple messages have been revised. If so, a special case fix for one test would be insufficient.

@chrstphrchvz
Copy link
Contributor Author

@chrstphrchvz The title and linked tcl issue suggest that multiple messages have been revised. If so, a special case fix for one test would be insufficient.

Understood, however this is currently the only test I have found to be affected by alphabetizing changes.

@terryjreedy
Copy link
Member

terryjreedy commented May 22, 2023

Then I made a PR to fix just that test.

terryjreedy added a commit to terryjreedy/cpython that referenced this issue May 23, 2023
For test_widgets.MenuTest.test_configure_type, the options
in the error message change to alphabetical order.
terryjreedy added a commit that referenced this issue May 27, 2023
* gh-104497: Make tkinter test pass with tk 8.7

For test_widgets.MenuTest.test_configure_type, the options
in the error message change to alphabetical order.

* Update Lib/test/test_tkinter/test_widgets.py

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>

---------

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 27, 2023
* pythongh-104497: Make tkinter test pass with tk 8.7

For test_widgets.MenuTest.test_configure_type, the options
in the error message change to alphabetical order.

* Update Lib/test/test_tkinter/test_widgets.py

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>

---------

(cherry picked from commit 897e716)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 27, 2023
* pythongh-104497: Make tkinter test pass with tk 8.7

For test_widgets.MenuTest.test_configure_type, the options
in the error message change to alphabetical order.

* Update Lib/test/test_tkinter/test_widgets.py

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>

---------

(cherry picked from commit 897e716)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
terryjreedy added a commit that referenced this issue May 27, 2023
…5028)

For test_widgets.MenuTest.test_configure_type, the options
in the error message change to alphabetical order.
---------

(cherry picked from commit 897e716)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
terryjreedy added a commit that referenced this issue May 27, 2023
…5029)

For test_widgets.MenuTest.test_configure_type, the options
in the error message change to alphabetical order.
---------

(cherry picked from commit 897e716)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir topic-tkinter type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants