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

test_tk fails on OS X with multiple test case failures with both Tk 8.5 and 8.4 #63960

Closed
ned-deily opened this issue Nov 25, 2013 · 6 comments
Closed
Assignees
Labels
tests Tests in the Lib/test dir topic-tkinter type-bug An unexpected behavior, bug, or error

Comments

@ned-deily
Copy link
Member

BPO 19761
Nosy @ned-deily, @serhiy-storchaka
Files
  • issue19761.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2014-02-03.20:33:48.716>
    created_at = <Date 2013-11-25.00:05:35.610>
    labels = ['tests', 'type-bug', 'expert-tkinter']
    title = 'test_tk fails on OS X with multiple test case failures with both Tk 8.5 and 8.4'
    updated_at = <Date 2014-02-03.20:33:48.716>
    user = 'https://github.com/ned-deily'

    bugs.python.org fields:

    activity = <Date 2014-02-03.20:33:48.716>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2014-02-03.20:33:48.716>
    closer = 'serhiy.storchaka'
    components = ['Tests', 'Tkinter']
    creation = <Date 2013-11-25.00:05:35.610>
    creator = 'ned.deily'
    dependencies = []
    files = ['33871']
    hgrepos = []
    issue_num = 19761
    keywords = ['patch']
    message_count = 6.0
    messages = ['204285', '209876', '210010', '210032', '210156', '210164']
    nosy_count = 3.0
    nosy_names = ['ned.deily', 'python-dev', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue19761'
    versions = ['Python 2.7', 'Python 3.3', 'Python 3.4']

    @ned-deily
    Copy link
    Member Author

    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

    @ned-deily ned-deily added tests Tests in the Lib/test dir topic-tkinter labels Nov 25, 2013
    @serhiy-storchaka serhiy-storchaka self-assigned this Dec 25, 2013
    @ned-deily
    Copy link
    Member Author

    There are three different classes of errors here:

    1. test_debug AssertionError: '0' != 0

    This has already been fixed by 7dab4feec126/05e84d3ecd1e/e7d922d8ee03 for bpo-6517.

    1. 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', '.')
    
    1. 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.

    @serhiy-storchaka
    Copy link
    Member

    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).

    @ned-deily
    Copy link
    Member Author

    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!

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Feb 3, 2014

    New changeset 129eb818d9b2 by Serhiy Storchaka in branch '2.7':
    Issue bpo-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 bpo-19761: Fixed Tkinter tests on OS X.
    http://hg.python.org/cpython/rev/76cd2e59b13d

    New changeset 2efe0778a4cf by Serhiy Storchaka in branch 'default':
    Issue bpo-19761: Fixed Tkinter tests on OS X.
    http://hg.python.org/cpython/rev/2efe0778a4cf

    @serhiy-storchaka
    Copy link
    Member

    Thank you Ned.

    @serhiy-storchaka serhiy-storchaka added the type-bug An unexpected behavior, bug, or error label Feb 3, 2014
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    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

    2 participants