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

Certain Tkinter tests fail on Tk 8.7 due to TIP 577 #104855

Closed
Tracked by #104568
chrstphrchvz opened this issue May 24, 2023 · 3 comments
Closed
Tracked by #104568

Certain Tkinter tests fail on Tk 8.7 due to TIP 577 #104855

chrstphrchvz opened this issue May 24, 2023 · 3 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 24, 2023

One of the broader effects of TIP 577 on Tk 8.7 (and to a greater degree under Tcl 9.0 than Tcl 8.7) is that it makes widget commands/options/etc. more consistent about using empty string as the reserved “none” value, rather than e.g. "none" or -1. #103685 was one instance of this.

Several options already accepted the empty string under Tk 8.6, but this was not reflected in the bad option… error messages. Tk 8.7 corrects this, which breaks several Tkinter tests with hardcoded error messages:

======================================================================
FAIL: test_place_configure_relheight (test.test_tkinter.test_geometry_managers.PlaceTest.test_place_configure_relheight)
----------------------------------------------------------------------
_tkinter.TclError: expected floating-point number or "" but got "abcd"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/user/git/cpython/Lib/test/test_tkinter/test_geometry_managers.py", line 426, in test_place_configure_relheight
    with self.assertRaisesRegex(TclError, 'expected floating-point number '
AssertionError: "expected floating-point number but got "abcd"" does not match "expected floating-point number or "" but got "abcd""

======================================================================
FAIL: test_place_configure_relwidth (test.test_tkinter.test_geometry_managers.PlaceTest.test_place_configure_relwidth)
----------------------------------------------------------------------
_tkinter.TclError: expected floating-point number or "" but got "abcd"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/user/git/cpython/Lib/test/test_tkinter/test_geometry_managers.py", line 414, in test_place_configure_relwidth
    with self.assertRaisesRegex(TclError, 'expected floating-point number '
AssertionError: "expected floating-point number but got "abcd"" does not match "expected floating-point number or "" but got "abcd""

======================================================================
FAIL: test_configure_overrelief (test.test_tkinter.test_widgets.ButtonTest.test_configure_overrelief)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/user/git/cpython/Lib/test/test_tkinter/widget_tests.py", line 448, in test_configure_overrelief
    self.checkReliefParam(widget, 'overrelief')
  File "/Users/user/git/cpython/Lib/test/test_tkinter/widget_tests.py", line 161, in checkReliefParam
    self.checkInvalidParam(widget, name, 'spam',
  File "/Users/user/git/cpython/Lib/test/test_tkinter/widget_tests.py", line 63, in checkInvalidParam
    self.assertEqual(str(cm.exception), errmsg)
AssertionError: 'bad relief "spam": must be flat, groove, raised, ridge, solid, sunken, or ""' != 'bad relief "spam": must be flat, groove, raised, ridge, solid, or sunken'
- bad relief "spam": must be flat, groove, raised, ridge, solid, sunken, or ""
?                                                                      -------
+ bad relief "spam": must be flat, groove, raised, ridge, solid, or sunken
?                                                                +++

======================================================================
FAIL: test_configure_overrelief (test.test_tkinter.test_widgets.CheckbuttonTest.test_configure_overrelief)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/user/git/cpython/Lib/test/test_tkinter/widget_tests.py", line 448, in test_configure_overrelief
    self.checkReliefParam(widget, 'overrelief')
  File "/Users/user/git/cpython/Lib/test/test_tkinter/widget_tests.py", line 161, in checkReliefParam
    self.checkInvalidParam(widget, name, 'spam',
  File "/Users/user/git/cpython/Lib/test/test_tkinter/widget_tests.py", line 63, in checkInvalidParam
    self.assertEqual(str(cm.exception), errmsg)
AssertionError: 'bad relief "spam": must be flat, groove, raised, ridge, solid, sunken, or ""' != 'bad relief "spam": must be flat, groove, raised, ridge, solid, or sunken'
- bad relief "spam": must be flat, groove, raised, ridge, solid, sunken, or ""
?                                                                      -------
+ bad relief "spam": must be flat, groove, raised, ridge, solid, or sunken
?                                                                +++

======================================================================
FAIL: test_configure_proxyrelief (test.test_tkinter.test_widgets.PanedWindowTest.test_configure_proxyrelief)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/user/git/cpython/Lib/test/test_tkinter/support.py", line 94, in newtest
    test(self)
  File "/Users/user/git/cpython/Lib/test/test_tkinter/test_widgets.py", line 1245, in test_configure_proxyrelief
    self.checkReliefParam(widget, 'proxyrelief')
  File "/Users/user/git/cpython/Lib/test/test_tkinter/widget_tests.py", line 161, in checkReliefParam
    self.checkInvalidParam(widget, name, 'spam',
  File "/Users/user/git/cpython/Lib/test/test_tkinter/widget_tests.py", line 63, in checkInvalidParam
    self.assertEqual(str(cm.exception), errmsg)
AssertionError: 'bad relief "spam": must be flat, groove, raised, ridge, solid, sunken, or ""' != 'bad relief "spam": must be flat, groove, raised, ridge, solid, or sunken'
- bad relief "spam": must be flat, groove, raised, ridge, solid, sunken, or ""
?                                                                      -------
+ bad relief "spam": must be flat, groove, raised, ridge, solid, or sunken
?                                                                +++

======================================================================
FAIL: test_configure_overrelief (test.test_tkinter.test_widgets.RadiobuttonTest.test_configure_overrelief)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/user/git/cpython/Lib/test/test_tkinter/widget_tests.py", line 448, in test_configure_overrelief
    self.checkReliefParam(widget, 'overrelief')
  File "/Users/user/git/cpython/Lib/test/test_tkinter/widget_tests.py", line 161, in checkReliefParam
    self.checkInvalidParam(widget, name, 'spam',
  File "/Users/user/git/cpython/Lib/test/test_tkinter/widget_tests.py", line 63, in checkInvalidParam
    self.assertEqual(str(cm.exception), errmsg)
AssertionError: 'bad relief "spam": must be flat, groove, raised, ridge, solid, sunken, or ""' != 'bad relief "spam": must be flat, groove, raised, ridge, solid, or sunken'
- bad relief "spam": must be flat, groove, raised, ridge, solid, sunken, or ""
?                                                                      -------
+ bad relief "spam": must be flat, groove, raised, ridge, solid, or sunken
?                                                                +++

In a few other cases, empty string has become a valid input, so tests which expect an exception to be raised now fail instead:

======================================================================
FAIL: test_configure_underline (test.test_tkinter.test_widgets.ButtonTest.test_configure_underline)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/user/git/cpython/Lib/test/test_tkinter/widget_tests.py", line 418, in test_configure_underline
    self.checkIntegerParam(widget, 'underline', 0, 1, 10)
  File "/Users/user/git/cpython/Lib/test/test_tkinter/widget_tests.py", line 77, in checkIntegerParam
    self.checkInvalidParam(widget, name, '',
  File "/Users/user/git/cpython/Lib/test/test_tkinter/widget_tests.py", line 60, in checkInvalidParam
    with self.assertRaises(tkinter.TclError) as cm:
AssertionError: TclError not raised

======================================================================
FAIL: test_configure_underline (test.test_tkinter.test_widgets.CheckbuttonTest.test_configure_underline)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/user/git/cpython/Lib/test/test_tkinter/widget_tests.py", line 418, in test_configure_underline
    self.checkIntegerParam(widget, 'underline', 0, 1, 10)
  File "/Users/user/git/cpython/Lib/test/test_tkinter/widget_tests.py", line 77, in checkIntegerParam
    self.checkInvalidParam(widget, name, '',
  File "/Users/user/git/cpython/Lib/test/test_tkinter/widget_tests.py", line 60, in checkInvalidParam
    with self.assertRaises(tkinter.TclError) as cm:
AssertionError: TclError not raised

======================================================================
FAIL: test_configure_underline (test.test_tkinter.test_widgets.LabelTest.test_configure_underline)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/user/git/cpython/Lib/test/test_tkinter/widget_tests.py", line 418, in test_configure_underline
    self.checkIntegerParam(widget, 'underline', 0, 1, 10)
  File "/Users/user/git/cpython/Lib/test/test_tkinter/widget_tests.py", line 77, in checkIntegerParam
    self.checkInvalidParam(widget, name, '',
  File "/Users/user/git/cpython/Lib/test/test_tkinter/widget_tests.py", line 60, in checkInvalidParam
    with self.assertRaises(tkinter.TclError) as cm:
AssertionError: TclError not raised

======================================================================
FAIL: test_configure_underline (test.test_tkinter.test_widgets.MenubuttonTest.test_configure_underline)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/user/git/cpython/Lib/test/test_tkinter/widget_tests.py", line 418, in test_configure_underline
    self.checkIntegerParam(widget, 'underline', 0, 1, 10)
  File "/Users/user/git/cpython/Lib/test/test_tkinter/widget_tests.py", line 77, in checkIntegerParam
    self.checkInvalidParam(widget, name, '',
  File "/Users/user/git/cpython/Lib/test/test_tkinter/widget_tests.py", line 60, in checkInvalidParam
    with self.assertRaises(tkinter.TclError) as cm:
AssertionError: TclError not raised

======================================================================
FAIL: test_configure_underline (test.test_tkinter.test_widgets.OptionMenuTest.test_configure_underline)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/user/git/cpython/Lib/test/test_tkinter/widget_tests.py", line 418, in test_configure_underline
    self.checkIntegerParam(widget, 'underline', 0, 1, 10)
  File "/Users/user/git/cpython/Lib/test/test_tkinter/widget_tests.py", line 77, in checkIntegerParam
    self.checkInvalidParam(widget, name, '',
  File "/Users/user/git/cpython/Lib/test/test_tkinter/widget_tests.py", line 60, in checkInvalidParam
    with self.assertRaises(tkinter.TclError) as cm:
AssertionError: TclError not raised

======================================================================
FAIL: test_configure_underline (test.test_tkinter.test_widgets.RadiobuttonTest.test_configure_underline)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/user/git/cpython/Lib/test/test_tkinter/widget_tests.py", line 418, in test_configure_underline
    self.checkIntegerParam(widget, 'underline', 0, 1, 10)
  File "/Users/user/git/cpython/Lib/test/test_tkinter/widget_tests.py", line 77, in checkIntegerParam
    self.checkInvalidParam(widget, name, '',
  File "/Users/user/git/cpython/Lib/test/test_tkinter/widget_tests.py", line 60, in checkInvalidParam
    with self.assertRaises(tkinter.TclError) as cm:
AssertionError: TclError not raised

Linked PRs

@chrstphrchvz chrstphrchvz changed the title Tkinter tests broken on Tk 8.7 due to TIP 577 Tkinter tests fail on Tk 8.7 due to TIP 577 May 24, 2023
@chrstphrchvz chrstphrchvz changed the title Tkinter tests fail on Tk 8.7 due to TIP 577 Certain Tkinter tests fail on Tk 8.7 due to TIP 577 May 24, 2023
@terryjreedy terryjreedy added topic-tkinter type-bug An unexpected behavior, bug, or error tests Tests in the Lib/test dir labels May 24, 2023
terryjreedy added a commit to terryjreedy/cpython that referenced this issue May 29, 2023
Where applicable:
* Add '' to the valid options in error messages.
* Test that '' is valid.
* Test that 'to' < 'from' is valid instead of invalid.

This PR also fixes pythongh-104856.
@terryjreedy
Copy link
Member

In the PR, the 4 groups of errors: place error messages, relief error messages, '' not failing, and 'to' < 'from' working (Spinbox), required fixes in 4 places in 3 files. Where applicable, new success tests were added.

@serhiy-storchaka
Copy link
Member

test_keys is failed due to the Tk bug: https://core.tcl-lang.org/tk/tktview/e64820c1dea2ffe69ae7d704dd48fa0098e7ad84

test_pane and test_forget crash due to the Tk bug: https://core.tcl-lang.org/tk/tktview/e6140f34047ea6f62a9aa636ae73dfe09bb6dafb

serhiy-storchaka added a commit that referenced this issue Jun 22, 2024
The tests are now passed with the current version of Tcl/Tk under
development (8.7b1+ and 9.0b3+).

The following changes were also made to make the tests more flexible:

* Helper methods like checkParam() now interpret the expected error message
  as a regular expression instead of a literal.
* Add support of new arguments in checkEnumParam():
  - allow_empty=True skips testing with empty string;
  - fullname= specifies the name for error message if it differs from the
    option name;
  - sort=True sorts values for error message.
* Add support of the allow_empty argument in checkReliefParam():
  allow_empty=True adds an empty string to the list of accepted values.
* Attributes _clip_highlightthickness, _clip_pad and  _clip_borderwidth
  specify how negative values of options -highlightthickness, -padx, -pady
  and -borderwidth are handled.
* Use global variables for some common error messages.

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jun 22, 2024
…H-120824)

The tests are now passed with the current version of Tcl/Tk under
development (8.7b1+ and 9.0b3+).

The following changes were also made to make the tests more flexible:

* Helper methods like checkParam() now interpret the expected error message
  as a regular expression instead of a literal.
* Add support of new arguments in checkEnumParam():
  - allow_empty=True skips testing with empty string;
  - fullname= specifies the name for error message if it differs from the
    option name;
  - sort=True sorts values for error message.
* Add support of the allow_empty argument in checkReliefParam():
  allow_empty=True adds an empty string to the list of accepted values.
* Attributes _clip_highlightthickness, _clip_pad and  _clip_borderwidth
  specify how negative values of options -highlightthickness, -padx, -pady
  and -borderwidth are handled.
* Use global variables for some common error messages.

(cherry picked from commit 6ad26de)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jun 22, 2024
…H-120824)

The tests are now passed with the current version of Tcl/Tk under
development (8.7b1+ and 9.0b3+).

The following changes were also made to make the tests more flexible:

* Helper methods like checkParam() now interpret the expected error message
  as a regular expression instead of a literal.
* Add support of new arguments in checkEnumParam():
  - allow_empty=True skips testing with empty string;
  - fullname= specifies the name for error message if it differs from the
    option name;
  - sort=True sorts values for error message.
* Add support of the allow_empty argument in checkReliefParam():
  allow_empty=True adds an empty string to the list of accepted values.
* Attributes _clip_highlightthickness, _clip_pad and  _clip_borderwidth
  specify how negative values of options -highlightthickness, -padx, -pady
  and -borderwidth are handled.
* Use global variables for some common error messages.

(cherry picked from commit 6ad26de)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
@serhiy-storchaka
Copy link
Member

The above bugs were fixed in Tcl/Tk. Many other changes were made in Tcl/Tk, and will be made before release. I merged test changes which make the Tkinter tests compatible with the current developing version of Tcl/Tk, although it is expected that more changes will be needed for the final version. But this allows us to run tests and see if something more serious were broken (like the bugs mentioned above).

serhiy-storchaka added a commit that referenced this issue Jun 22, 2024
) (GH-120865)

The tests are now passed with the current version of Tcl/Tk under
development (8.7b1+ and 9.0b3+).

The following changes were also made to make the tests more flexible:

* Helper methods like checkParam() now interpret the expected error message
  as a regular expression instead of a literal.
* Add support of new arguments in checkEnumParam():
  - allow_empty=True skips testing with empty string;
  - fullname= specifies the name for error message if it differs from the
    option name;
  - sort=True sorts values for error message.
* Add support of the allow_empty argument in checkReliefParam():
  allow_empty=True adds an empty string to the list of accepted values.
* Attributes _clip_highlightthickness, _clip_pad and  _clip_borderwidth
  specify how negative values of options -highlightthickness, -padx, -pady
  and -borderwidth are handled.
* Use global variables for some common error messages.

(cherry picked from commit 6ad26de)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
serhiy-storchaka added a commit that referenced this issue Jun 22, 2024
) (GH-120864)

The tests are now passed with the current version of Tcl/Tk under
development (8.7b1+ and 9.0b3+).

The following changes were also made to make the tests more flexible:

* Helper methods like checkParam() now interpret the expected error message
  as a regular expression instead of a literal.
* Add support of new arguments in checkEnumParam():
  - allow_empty=True skips testing with empty string;
  - fullname= specifies the name for error message if it differs from the
    option name;
  - sort=True sorts values for error message.
* Add support of the allow_empty argument in checkReliefParam():
  allow_empty=True adds an empty string to the list of accepted values.
* Attributes _clip_highlightthickness, _clip_pad and  _clip_borderwidth
  specify how negative values of options -highlightthickness, -padx, -pady
  and -borderwidth are handled.
* Use global variables for some common error messages.

(cherry picked from commit 6ad26de)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
mrahtz pushed a commit to mrahtz/cpython that referenced this issue Jun 30, 2024
…H-120824)

The tests are now passed with the current version of Tcl/Tk under
development (8.7b1+ and 9.0b3+).

The following changes were also made to make the tests more flexible:

* Helper methods like checkParam() now interpret the expected error message
  as a regular expression instead of a literal.
* Add support of new arguments in checkEnumParam():
  - allow_empty=True skips testing with empty string;
  - fullname= specifies the name for error message if it differs from the
    option name;
  - sort=True sorts values for error message.
* Add support of the allow_empty argument in checkReliefParam():
  allow_empty=True adds an empty string to the list of accepted values.
* Attributes _clip_highlightthickness, _clip_pad and  _clip_borderwidth
  specify how negative values of options -highlightthickness, -padx, -pady
  and -borderwidth are handled.
* Use global variables for some common error messages.

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
noahbkim pushed a commit to hudson-trading/cpython that referenced this issue Jul 11, 2024
…H-120824)

The tests are now passed with the current version of Tcl/Tk under
development (8.7b1+ and 9.0b3+).

The following changes were also made to make the tests more flexible:

* Helper methods like checkParam() now interpret the expected error message
  as a regular expression instead of a literal.
* Add support of new arguments in checkEnumParam():
  - allow_empty=True skips testing with empty string;
  - fullname= specifies the name for error message if it differs from the
    option name;
  - sort=True sorts values for error message.
* Add support of the allow_empty argument in checkReliefParam():
  allow_empty=True adds an empty string to the list of accepted values.
* Attributes _clip_highlightthickness, _clip_pad and  _clip_borderwidth
  specify how negative values of options -highlightthickness, -padx, -pady
  and -borderwidth are handled.
* Use global variables for some common error messages.

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
…H-120824)

The tests are now passed with the current version of Tcl/Tk under
development (8.7b1+ and 9.0b3+).

The following changes were also made to make the tests more flexible:

* Helper methods like checkParam() now interpret the expected error message
  as a regular expression instead of a literal.
* Add support of new arguments in checkEnumParam():
  - allow_empty=True skips testing with empty string;
  - fullname= specifies the name for error message if it differs from the
    option name;
  - sort=True sorts values for error message.
* Add support of the allow_empty argument in checkReliefParam():
  allow_empty=True adds an empty string to the list of accepted values.
* Attributes _clip_highlightthickness, _clip_pad and  _clip_borderwidth
  specify how negative values of options -highlightthickness, -padx, -pady
  and -borderwidth are handled.
* Use global variables for some common error messages.

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
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