Repository navigation
test_tkinter failing on MacOS #128846
Description
Activity
- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on Jan 14, 2025 I also reproduced this on an arbitrary older commit 2fcdc84 (and then b2ac70a)
If I go back to ce740d4, which I need to run the GUI tests on my machine, I get a bunch of failures — including what looks like the failures reported here. @smontanaro I don't know if it makes sense that these tests worked yesterday.
It looks like this is caused by using tk 9.0+, at least on my machine, Brew upgraded to a new version.
You can confirm with
❯ ./python.exe -c 'import tkinter; tcl = tkinter.Tcl(); print(tcl.call("info", "patchlevel"))' 9.0.1In which case, this is part of
- Update tkinter to use Tk 8.6.15 or (better) Tk 9.0 #124111
- Prepare tkinter for tcl 8.7/9.0 and tk 8.7 #104568
I don't think the tests are expected to pass with tk 9 yet.
Hmmm... This might turn out to be pilot error. I have a config file in my personal build environment which gets Tcl/Tk libs from my Conda env:
TCLTK_CFLAGS=-I/Users/skip/miniconda3/envs/python312/include TCLTK_LIBS='-L/Users/skip/miniconda3/envs/python312/lib -Wl,-rpath,/Users/skip/miniconda3/envs/python312/lib -ltk8.6 -ltkstub8.6 -ltcl8.6 -ltclstub8.6'Somehow that was dropped from a command recalled from my bash history, so I was picking up 9.0.1. Now that I've corrected my commands, my build on main works and yields the expected version:
% ./python.exe -c 'import tkinter; tcl = tkinter.Tcl(); print(tcl.call("info", "patchlevel"))' 8.6.13I've yet to pull in the correct command on my 3.13 Terminal window, so it still yields the later version:
% ./python.exe -c 'import tkinter; tcl = tkinter.Tcl(); print(tcl.call("info", "patchlevel"))' 9.0.1Would it be worthwhile running this bit of code in the test suite, then skipping the tests if Tcl/Tk v9 was found?
That seems reasonable to me, but I'd be curious to hear from someone that's a stakeholder for that topic.
cc @terryjreedy
This doesn't seem to be the cause of my commit, which passed macOS-related tests.
@serhiy-storchaka is the tkinter expert, not me. I would like to be able to use 9.0, but I don't know where that stands now.
FWIW, I see
test_tkinterblocking unrelated 3.13 backports, pretty consistently. On a local 3.13 branch, bothtest_tkinterandtest_ttkfail for me consistently too.% brew info tcl-tk ... ==> Installed Versions tcl-tk ✔ 9.0.3 (3,158 files, 40MB) [Linked]For me, they pass on all newer branches.
test_wm_iconbitmap has separate issue #146531. Other failures are not related to it.
The original report was 1.5 years ago, there were many changes in tests since then, especially in last month. Please check if the originally reported failure still reproduced (besides test_wm_iconbitmap). I have no Mac, so my capabilities to address Mac-only issues are limited.
@hugovk "fixed" the timeout, but I still see two actual failures:
0:01:55 load avg: 6.32 running (1): test_ttk (31.4 sec) 0:02:25 load avg: 5.86 running (1): test_ttk (1 min 1 sec) 0:02:55 load avg: 5.26 running (1): test_ttk (1 min 31 sec) 0:03:05 load avg: 4.90 [4/4/2] test_ttk failed (9 failures) (1 min 40 sec) Re-running test_ttk in verbose mode (matching: test_configure_image, test_configure_custom_copy, test_element_create_from_errors, test_configure_image, test_configure_image, test_virtual_event, test_configure_image, test_configure_image, test_configure_image) test_configure_image (test.test_ttk.test_extensions.OptionMenuTest.test_configure_image) ... FAIL test_configure_custom_copy (test.test_ttk.test_style.StyleTest.test_configure_custom_copy) ... test_configure_custom_copy (test.test_ttk.test_style.StyleTest.test_configure_custom_copy) (theme='aqua', name='.') ... FAIL test_element_create_from_errors (test.test_ttk.test_style.StyleTest.test_element_create_from_errors) ... FAIL test_configure_image (test.test_ttk.test_widgets.ButtonTest.test_configure_image) ... FAIL test_configure_image (test.test_ttk.test_widgets.CheckbuttonTest.test_configure_image) ... FAIL test_virtual_event (test.test_ttk.test_widgets.ComboboxTest.test_virtual_event) ... FAIL test_configure_image (test.test_ttk.test_widgets.LabelTest.test_configure_image) ... FAIL test_configure_image (test.test_ttk.test_widgets.MenubuttonTest.test_configure_image) ... FAIL test_configure_image (test.test_ttk.test_widgets.RadiobuttonTest.test_configure_image) ... FAIL ====================================================================== FAIL: test_configure_image (test.test_ttk.test_extensions.OptionMenuTest.test_configure_image) ---------------------------------------------------------------------- _tkinter.TclError: image "spam" does not exist During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/barry/projects/python/3.13/Lib/test/test_tkinter/widget_tests.py", line 376, in test_configure_image self.checkImageParam(widget, 'image') ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ File "/Users/barry/projects/python/3.13/Lib/test/test_ttk/test_widgets.py", line 185, in checkImageParam self.checkInvalidParam(widget, name, 'spam', ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^ errmsg='image "spam" doesn\'t exist') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/barry/projects/python/3.13/Lib/test/test_tkinter/widget_tests.py", line 80, in checkInvalidParam with self.assertRaisesRegex(tkinter.TclError, errmsg or ''): ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: "\Aimage "spam" doesn't exist\Z" does not match "image "spam" does not exist" ====================================================================== FAIL: test_configure_custom_copy (test.test_ttk.test_style.StyleTest.test_configure_custom_copy) (theme='aqua', name='.') ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/barry/projects/python/3.13/Lib/test/test_ttk/test_style.py", line 164, in test_configure_custom_copy self.assertEqual(style.configure(newname), default) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: {'font': 'TkDefaultFont', 'foreground': 'sy[193 chars]: ''} != {'selectforeground': 'systemSelectedTextCol[193 chars]': 1} {'background': 'systemWindowBackgroundColor', 'font': 'TkDefaultFont', 'foreground': 'systemLabelColor', 'insertwidth': 1, 'selectbackground': 'systemSelectedTextBackgroundColor', 'selectforeground': 'systemSelectedTextColor', - 'stipple': ''} ? ^^ + 'stipple': ()} ? ^^ ====================================================================== FAIL: test_element_create_from_errors (test.test_ttk.test_style.StyleTest.test_element_create_from_errors) ---------------------------------------------------------------------- _tkinter.TclError: theme "spam" does not exist During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/barry/projects/python/3.13/Lib/test/test_ttk/test_style.py", line 225, in test_element_create_from_errors with self.assertRaisesRegex(TclError, 'theme "spam" doesn\'t exist'): ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: "theme "spam" doesn't exist" does not match "theme "spam" does not exist" ====================================================================== FAIL: test_configure_image (test.test_ttk.test_widgets.ButtonTest.test_configure_image) ---------------------------------------------------------------------- _tkinter.TclError: image "spam" does not exist During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/barry/projects/python/3.13/Lib/test/test_tkinter/widget_tests.py", line 376, in test_configure_image self.checkImageParam(widget, 'image') ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ File "/Users/barry/projects/python/3.13/Lib/test/test_ttk/test_widgets.py", line 185, in checkImageParam self.checkInvalidParam(widget, name, 'spam', ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^ errmsg='image "spam" doesn\'t exist') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/barry/projects/python/3.13/Lib/test/test_tkinter/widget_tests.py", line 80, in checkInvalidParam with self.assertRaisesRegex(tkinter.TclError, errmsg or ''): ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: "\Aimage "spam" doesn't exist\Z" does not match "image "spam" does not exist" ====================================================================== FAIL: test_configure_image (test.test_ttk.test_widgets.CheckbuttonTest.test_configure_image) ---------------------------------------------------------------------- _tkinter.TclError: image "spam" does not exist During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/barry/projects/python/3.13/Lib/test/test_tkinter/widget_tests.py", line 376, in test_configure_image self.checkImageParam(widget, 'image') ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ File "/Users/barry/projects/python/3.13/Lib/test/test_ttk/test_widgets.py", line 185, in checkImageParam self.checkInvalidParam(widget, name, 'spam', ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^ errmsg='image "spam" doesn\'t exist') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/barry/projects/python/3.13/Lib/test/test_tkinter/widget_tests.py", line 80, in checkInvalidParam with self.assertRaisesRegex(tkinter.TclError, errmsg or ''): ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: "\Aimage "spam" doesn't exist\Z" does not match "image "spam" does not exist" ====================================================================== FAIL: test_virtual_event (test.test_ttk.test_widgets.ComboboxTest.test_virtual_event) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/barry/projects/python/3.13/Lib/test/test_ttk/test_widgets.py", line 506, in test_virtual_event self.assertTrue(success) ~~~~~~~~~~~~~~~^^^^^^^^^ AssertionError: [] is not true ====================================================================== FAIL: test_configure_image (test.test_ttk.test_widgets.LabelTest.test_configure_image) ---------------------------------------------------------------------- _tkinter.TclError: image "spam" does not exist During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/barry/projects/python/3.13/Lib/test/test_tkinter/widget_tests.py", line 376, in test_configure_image self.checkImageParam(widget, 'image') ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ File "/Users/barry/projects/python/3.13/Lib/test/test_ttk/test_widgets.py", line 185, in checkImageParam self.checkInvalidParam(widget, name, 'spam', ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^ errmsg='image "spam" doesn\'t exist') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/barry/projects/python/3.13/Lib/test/test_tkinter/widget_tests.py", line 80, in checkInvalidParam with self.assertRaisesRegex(tkinter.TclError, errmsg or ''): ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: "\Aimage "spam" doesn't exist\Z" does not match "image "spam" does not exist" ====================================================================== FAIL: test_configure_image (test.test_ttk.test_widgets.MenubuttonTest.test_configure_image) ---------------------------------------------------------------------- _tkinter.TclError: image "spam" does not exist During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/barry/projects/python/3.13/Lib/test/test_tkinter/widget_tests.py", line 376, in test_configure_image self.checkImageParam(widget, 'image') ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ File "/Users/barry/projects/python/3.13/Lib/test/test_ttk/test_widgets.py", line 185, in checkImageParam self.checkInvalidParam(widget, name, 'spam', ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^ errmsg='image "spam" doesn\'t exist') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/barry/projects/python/3.13/Lib/test/test_tkinter/widget_tests.py", line 80, in checkInvalidParam with self.assertRaisesRegex(tkinter.TclError, errmsg or ''): ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: "\Aimage "spam" doesn't exist\Z" does not match "image "spam" does not exist" ====================================================================== FAIL: test_configure_image (test.test_ttk.test_widgets.RadiobuttonTest.test_configure_image) ---------------------------------------------------------------------- _tkinter.TclError: image "spam" does not exist During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/barry/projects/python/3.13/Lib/test/test_tkinter/widget_tests.py", line 376, in test_configure_image self.checkImageParam(widget, 'image') ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ File "/Users/barry/projects/python/3.13/Lib/test/test_ttk/test_widgets.py", line 185, in checkImageParam self.checkInvalidParam(widget, name, 'spam', ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^ errmsg='image "spam" doesn\'t exist') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/barry/projects/python/3.13/Lib/test/test_tkinter/widget_tests.py", line 80, in checkInvalidParam with self.assertRaisesRegex(tkinter.TclError, errmsg or ''): ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: "\Aimage "spam" doesn't exist\Z" does not match "image "spam" does not exist" ---------------------------------------------------------------------- Ran 9 tests in 100.683s FAILED (failures=9) test test_ttk failed 2 tests failed again: test_tkinter test_ttk
I suspect it's because it's linking against Tcl/Tk 9.0.3 from homebrew and 3.13 isn't compatible with it. I'm not sure it's worth doing anything more in 3.13 given newer branches seem fine.
2 remaining items
#153484 does this.
Very close.
test_tkinternow passes. There's still a single test case failure intest_ttk:FAIL: test_configure_custom_copy (test.test_ttk.test_style.StyleTest.test_configure_custom_copy) (theme='aqua', name='.') ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/skip/src/python/py3.13/Lib/test/test_ttk/test_style.py", line 164, in test_configure_custom_copy self.assertEqual(style.configure(newname), default) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: {'font': 'TkDefaultFont', 'foreground': 'sy[193 chars]: ''} != {'selectforeground': 'systemSelectedTextCol[193 chars]': 1} {'background': 'systemWindowBackgroundColor', 'font': 'TkDefaultFont', 'foreground': 'systemLabelColor', 'insertwidth': 1, 'selectbackground': 'systemSelectedTextBackgroundColor', 'selectforeground': 'systemSelectedTextColor', - 'stipple': ''} ? ^^ + 'stipple': ()} ? ^^
Thanks for testing. This is Aqua-specific issue, not reproducible on Linux. Please check if #153611 fixes it.
Unfortunately, it doesn't. I get the same error after applying your patch:
% ./python.exe -m test -v -ugui test_ttk == CPython 3.13.14+ experimental free-threading build (heads/3.13:caa4be2d497, Jul 11 2026, 16:55:57) [Clang 22.1.8 ] == macOS-26.5.2-arm64-arm-64bit-Mach-O little-endian == Python build: free_threading release == cwd: /Users/skip/src/python/py3.13/build/test_python_worker_2401æ == CPU count: 8 == encodings: locale=UTF-8 FS=utf-8 == resources (1): gui Using random seed: 2083467248 0:00:00 load avg: 3.02 Run 1 test sequentially in a single process 0:00:00 load avg: 3.02 [1/1] test_ttk ... ====================================================================== FAIL: test_configure_custom_copy (test.test_ttk.test_style.StyleTest.test_configure_custom_copy) (theme='aqua', name='.') ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/skip/src/python/py3.13/Lib/test/test_ttk/test_style.py", line 170, in test_configure_custom_copy self.assertEqual({k: norm(v) for k, v in copy.items()}, ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ default) ^^^^^^^^ AssertionError: {'font': 'TkDefaultFont', 'foreground': 'sy[193 chars]: ''} != {'selectforeground': 'systemSelectedTextCol[193 chars]': 1} {'background': 'systemWindowBackgroundColor', 'font': 'TkDefaultFont', 'foreground': 'systemLabelColor', 'insertwidth': 1, 'selectbackground': 'systemSelectedTextBackgroundColor', 'selectforeground': 'systemSelectedTextColor', - 'stipple': ''} ? ^^ + 'stipple': ()} ? ^^ ---------------------------------------------------------------------- Ran 397 tests in 18.306s FAILED (failures=1, skipped=15) test test_ttk failed 0:00:18 load avg: 2.79 [1/1/1] test_ttk failed (1 failure) == Tests result: FAILURE == 1 test failed: test_ttk Total duration: 18.5 sec Total tests: run=397 failures=1 skipped=15 Total test files: run=1/1 failed=1 Result: FAILURE (py314) ~/src/python/py3.13% git diff diff --git a/Lib/test/test_ttk/test_style.py b/Lib/test/test_ttk/test_style.py index 56d8a5931fd..2e0a0384dd2 100644 --- a/Lib/test/test_ttk/test_style.py +++ b/Lib/test/test_ttk/test_style.py @@ -161,9 +161,17 @@ def test_configure_custom_copy(self): newname = f'C.{name}' self.assertEqual(style.configure(newname), None) style.configure(newname, **default) - self.assertEqual(style.configure(newname), default) + # With Tk 9 and the aqua theme an empty option value is + # read back as an empty tuple rather than an empty string + # (see gh-128846); normalize before comparing. + def norm(value): + return '' if value == () else value + copy = style.configure(newname) + self.assertEqual({k: norm(v) for k, v in copy.items()}, + default) for key, value in default.items(): - self.assertEqual(style.configure(newname, key), value) + self.assertEqual(norm(style.configure(newname, key)), + value) def test_map_custom_copy(self):What if replace
return '' if value == () else valuewithreturn () if value == '' else value?Yes, that works, thanks...
Unfortunately that change breaks CI testing.
Please test with the current 3.13 branch.
Current 3.13 branch tests cleanly. Sorry for not trying sooner. I don't seem to get all pertinent notifications.
Thank you for verification. I am closing this issue as completed.
Bug report
Bug description:
test_tkinteris failing on MacOS (Sequoia 15.2, M1 MacBook Pro, in my case). It was working fine yesterday, so without delving into this too deeply, I'm going to suggest this change overnight broke things. See attached log@Xiaokang2022
(FWIW,
test_ttkis failing for me on 3.13, but not main. It appears to be a different problem.)test_tkinter.log
CPython versions tested on:
CPython main branch, 3.13
Operating systems tested on:
macOS
Linked PRs