This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: test_tk fails on OS X with multiple test case failures with both Tk 8.5 and 8.4
Type: behavior Stage: resolved
Components: Tests, Tkinter Versions: Python 3.3, Python 3.4, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: ned.deily, python-dev, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2013-11-25 00:05 by ned.deily, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue19761.patch serhiy.storchaka, 2014-02-02 20:38 review
Messages (6)
msg204285 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2013-11-25 00:05
As of 3.4.0b1, the following test failures are observed with Tk 8.5 on OS X (python.org 64-/32- installer with ActiveTcl 8.5.15.1 on OS X 10.9):

======================================================================
FAIL: test_bitmap (tkinter.test.test_tkinter.test_widgets.ButtonTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tkinter/test/widget_tests.py", line 240, in test_bitmap
    errmsg='bitmap "spam" not defined')
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tkinter/test/widget_tests.py", line 75, in checkInvalidParam
    widget[name] = value
AssertionError: TclError not raised

======================================================================
FAIL: test_bitmap (tkinter.test.test_tkinter.test_widgets.CheckbuttonTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tkinter/test/widget_tests.py", line 240, in test_bitmap
    errmsg='bitmap "spam" not defined')
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tkinter/test/widget_tests.py", line 75, in checkInvalidParam
    widget[name] = value
AssertionError: TclError not raised

======================================================================
FAIL: test_insertborderwidth (tkinter.test.test_tkinter.test_widgets.EntryTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tkinter/test/test_tkinter/test_widgets.py", line 333, in test_insertborderwidth
    self.checkPixelsParam(widget, 'insertborderwidth', 0, 1.3, -2)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tkinter/test/widget_tests.py", line 169, in checkPixelsParam
    conv=conv1, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tkinter/test/widget_tests.py", line 59, in checkParam
    self.assertEqual2(widget[name], expected, eq=eq)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tkinter/test/widget_tests.py", line 43, in assertEqual2
    self.assertEqual(actual, expected, msg)
AssertionError: 0 != 1

======================================================================
FAIL: test_bitmap (tkinter.test.test_tkinter.test_widgets.LabelTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tkinter/test/widget_tests.py", line 240, in test_bitmap
    errmsg='bitmap "spam" not defined')
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tkinter/test/widget_tests.py", line 75, in checkInvalidParam
    widget[name] = value
AssertionError: TclError not raised

======================================================================
FAIL: test_bitmap (tkinter.test.test_tkinter.test_widgets.MenubuttonTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tkinter/test/widget_tests.py", line 240, in test_bitmap
    errmsg='bitmap "spam" not defined')
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tkinter/test/widget_tests.py", line 75, in checkInvalidParam
    widget[name] = value
AssertionError: TclError not raised

======================================================================
FAIL: test_bitmap (tkinter.test.test_tkinter.test_widgets.OptionMenuTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tkinter/test/widget_tests.py", line 240, in test_bitmap
    errmsg='bitmap "spam" not defined')
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tkinter/test/widget_tests.py", line 75, in checkInvalidParam
    widget[name] = value
AssertionError: TclError not raised

======================================================================
FAIL: test_bitmap (tkinter.test.test_tkinter.test_widgets.RadiobuttonTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tkinter/test/widget_tests.py", line 240, in test_bitmap
    errmsg='bitmap "spam" not defined')
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tkinter/test/widget_tests.py", line 75, in checkInvalidParam
    widget[name] = value
AssertionError: TclError not raised

======================================================================
FAIL: test_insertborderwidth (tkinter.test.test_tkinter.test_widgets.SpinboxTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tkinter/test/test_tkinter/test_widgets.py", line 333, in test_insertborderwidth
    self.checkPixelsParam(widget, 'insertborderwidth', 0, 1.3, -2)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tkinter/test/widget_tests.py", line 169, in checkPixelsParam
    conv=conv1, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tkinter/test/widget_tests.py", line 59, in checkParam
    self.assertEqual2(widget[name], expected, eq=eq)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tkinter/test/widget_tests.py", line 43, in assertEqual2
    self.assertEqual(actual, expected, msg)
AssertionError: 0 != 1

----------------------------------------------------------------------


The following test failures are observed with Tk 8.4 on OS X (python.org 32-only installer with ActiveTcl 8.4.20 on OS X 10.5.8):

======================================================================
FAIL: test_debug (tkinter.test.test_tkinter.test_text.TextTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tkinter/test/test_tkinter/test_text.py", line 22, in test_debug
    self.assertEqual(text.debug(), 0)
AssertionError: '0' != 0

======================================================================
FAIL: test_insertborderwidth (tkinter.test.test_tkinter.test_widgets.EntryTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tkinter/test/test_tkinter/test_widgets.py", line 333, in test_insertborderwidth
    self.checkPixelsParam(widget, 'insertborderwidth', 0, 1.3, -2)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tkinter/test/widget_tests.py", line 169, in checkPixelsParam
    conv=conv1, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tkinter/test/widget_tests.py", line 59, in checkParam
    self.assertEqual2(widget[name], expected, eq=eq)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tkinter/test/widget_tests.py", line 43, in assertEqual2
    self.assertEqual(actual, expected, msg)
AssertionError: 0 != 1

======================================================================
FAIL: test_insertborderwidth (tkinter.test.test_tkinter.test_widgets.SpinboxTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tkinter/test/test_tkinter/test_widgets.py", line 333, in test_insertborderwidth
    self.checkPixelsParam(widget, 'insertborderwidth', 0, 1.3, -2)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tkinter/test/widget_tests.py", line 169, in checkPixelsParam
    conv=conv1, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tkinter/test/widget_tests.py", line 59, in checkParam
    self.assertEqual2(widget[name], expected, eq=eq)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tkinter/test/widget_tests.py", line 43, in assertEqual2
    self.assertEqual(actual, expected, msg)
AssertionError: 0 != 1

----------------------------------------------------------------------
msg209876 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2014-02-01 07:02
There are three different classes of errors here:

1. test_debug AssertionError: '0' != 0

This has already been fixed by 7dab4feec126/05e84d3ecd1e/e7d922d8ee03 for Issue6517.


2. test_bitmap checks for invalid bitmap values do not fail as expected with Cocoa Tk

This appears to be a bug in Cocoa Tk, reproducible with the wish shell.  I've opened a Tk issue for it:

https://core.tcl.tk/tk/tktview?name=31cd33dbf0

The simplest approach would be to just skip test_bitmap for OS X until this is fixed.  A more focused workaround patch would be to only skip the checkInvalidParam test when running under Cocoa Tk:

    'aqua' in root.tk.call('tk', 'windowingsystem') and
    'AppKit' in root.tk.call('winfo', 'server', '.')


3. test_insertborderwidth failures for Entry and Spinbox widgets

After a little investigation, I think this is a test case error. at least for Entry.  According to third-party Tkinter documentation (http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/entry.html) for the Entry widget:

"By default, the insertion cursor is a simple rectangle. You can get the cursor with the tk.RAISED relief effect (see Section 5.6, 'Relief styles') by setting insertborderwidth to the dimension of the 3-d border. If you do, make sure that the insertwidth option is at least twice that value."

It looks like for both the OS X Carbon (8.4) and Cocoa (8.5 and 8.6) Tks, the restriction about insertwidth is enforced, but with the X11 Tk, it is not.

Some examples using Cocoa Tk (8.5.15) and 3.4.0b3:
>>> from tkinter import *; r = Tk()
>>> w = Entry(r, insertborderwidth=1.3); w.pack(); w['insertborderwidth']
0
>>> w = Entry(r, insertborderwidth=1.3, insertwidth=10); w.pack(); w['insertborderwidth']
1
>>> w = Entry(r, insertborderwidth=2); w.pack(); w['insertborderwidth']
0
>>> w = Entry(r, insertborderwidth=2, insertwidth=10); w.pack(); w['insertborderwidth']
2
>>> w = Entry(r, insertborderwidth='10p'); w.pack(); w['insertborderwidth']
0
>>> w = Entry(r, insertborderwidth='10p', insertwidth=10); w.pack(); w['insertborderwidth']
5

Using X11 Tk (8.6.1) on OS X:
>>> from tkinter import *; r = Tk()
>>> w = Entry(r, insertborderwidth=1.3); w.pack(); w['insertborderwidth']
1
>>> w = Entry(r, insertborderwidth=1.3, insertwidth=10); w.pack(); w['insertborderwidth']
1
>>> w = Entry(r, insertborderwidth=2); w.pack(); w['insertborderwidth']
1
>>> w = Entry(r, insertborderwidth=2, insertwidth=10); w.pack(); w['insertborderwidth']
2
>>> w = Entry(r, insertborderwidth='10p'); w.pack(); w['insertborderwidth']
1
>>> w = Entry(r, insertborderwidth='10p', insertwidth=10); w.pack(); w['insertborderwidth']
5

So it appears the tests could be made to pass on OS X Cocoa and Carbon Tks and on X11 Tks if insertwidth is also set on the insertborderwidth tests.  That would need to be tested with Windows Tk.
msg210010 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-02-02 20:38
Thank you Ned for your great investigation.

Here is a patch for these two bugs.

A test for invalid bitmap is skipped (also added a test for bitmap specified in external file). For insertborderwidth tests the insertwidth value is explicitly increased (yes, the Tk source code bounds insertborderwidth by insertwidth/2).
msg210032 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2014-02-02 22:07
The supplied patch fixed all of the failing test cases on OS X, tested on 3.3 and default with Cocoa Tk 8.5 & 8.6, Carbon Tk 8.4, and X11 Tk 8.6.  I'll test on 2.7 after the modified patch is applied.  Thanks, Serhiy!
msg210156 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-02-03 19:39
New changeset 129eb818d9b2 by Serhiy Storchaka in branch '2.7':
Issue #19761: Fixed Tkinter tests on OS X.
http://hg.python.org/cpython/rev/129eb818d9b2

New changeset 76cd2e59b13d by Serhiy Storchaka in branch '3.3':
Issue #19761: Fixed Tkinter tests on OS X.
http://hg.python.org/cpython/rev/76cd2e59b13d

New changeset 2efe0778a4cf by Serhiy Storchaka in branch 'default':
Issue #19761: Fixed Tkinter tests on OS X.
http://hg.python.org/cpython/rev/2efe0778a4cf
msg210164 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-02-03 20:33
Thank you Ned.
History
Date User Action Args
2022-04-11 14:57:54adminsetgithub: 63960
2014-02-03 20:33:48serhiy.storchakasetstatus: open -> closed
type: behavior
messages: + msg210164

resolution: fixed
stage: commit review -> resolved
2014-02-03 19:39:32python-devsetnosy: + python-dev
messages: + msg210156
2014-02-02 22:07:16ned.deilysetstage: patch review -> commit review
messages: + msg210032
versions: + Python 2.7
2014-02-02 20:38:53serhiy.storchakasetfiles: + issue19761.patch
keywords: + patch
messages: + msg210010

stage: needs patch -> patch review
2014-02-01 07:02:11ned.deilysetmessages: + msg209876
versions: + Python 3.3
2013-12-25 20:38:06serhiy.storchakasetassignee: serhiy.storchaka
2013-11-25 00:05:35ned.deilycreate