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 test_font fails on OS X with Aqua Tk #54108

Closed
donmez mannequin opened this issue Sep 19, 2010 · 10 comments
Closed

tkinter test_font fails on OS X with Aqua Tk #54108

donmez mannequin opened this issue Sep 19, 2010 · 10 comments
Labels
tests Tests in the Lib/test dir topic-tkinter type-bug An unexpected behavior, bug, or error

Comments

@donmez
Copy link
Mannequin

donmez mannequin commented Sep 19, 2010

BPO 9899
Nosy @amauryfa, @pitrou, @ned-deily
Files
  • issue9899-py3k.patch
  • issue9899-fix1-py3k.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 = None
    closed_at = <Date 2010-10-05.12:43:16.162>
    created_at = <Date 2010-09-19.20:42:57.462>
    labels = ['tests', 'type-bug', 'expert-tkinter']
    title = 'tkinter test_font fails on OS X with Aqua Tk'
    updated_at = <Date 2010-10-05.12:43:16.161>
    user = 'https://bugs.python.org/donmez'

    bugs.python.org fields:

    activity = <Date 2010-10-05.12:43:16.161>
    actor = 'pitrou'
    assignee = 'none'
    closed = True
    closed_date = <Date 2010-10-05.12:43:16.162>
    closer = 'pitrou'
    components = ['Tests', 'Tkinter']
    creation = <Date 2010-09-19.20:42:57.462>
    creator = 'donmez'
    dependencies = []
    files = ['18934', '19130']
    hgrepos = []
    issue_num = 9899
    keywords = ['patch']
    message_count = 10.0
    messages = ['116883', '116906', '116933', '117023', '117080', '117414', '117420', '117990', '118003', '118007']
    nosy_count = 5.0
    nosy_names = ['amaury.forgeotdarc', 'pitrou', 'donmez', 'gpolo', 'ned.deily']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue9899'
    versions = ['Python 3.2']

    @donmez
    Copy link
    Mannequin Author

    donmez mannequin commented Sep 19, 2010

    py3k branch, revision 84907

    ======================================================================
    ERROR: test_font_eq (tkinter.test.test_tkinter.test_font.FontTest)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/Users/cartman/Sources/py3k/Lib/tkinter/test/test_tkinter/test_font.py", line 10, in test_font_eq
        font1 = font.nametofont("system")
      File "/Users/cartman/Sources/py3k/Lib/tkinter/font.py", line 22, in nametofont
        return Font(name=name, exists=True)
      File "/Users/cartman/Sources/py3k/Lib/tkinter/font.py", line 83, in __init__
        "named font %s does not already exist" % (self.name,))
    _tkinter.TclError: named font system does not already exist

    @donmez donmez mannequin added tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error labels Sep 19, 2010
    @ned-deily
    Copy link
    Member

    r84865 for bpo-1730136 introduced a new tkinter test, test_font. As it stands, the test fails on OS X 10.6 when Python is built with Aqua Tk, at least with either the Apple-supplied 8.5 or the ActiveState 8.5 (I haven't tried with any of the Aqua 8.4 version). The main problem is that font "system" is not a font name returned by the interface used by tkinter/font.py:

    $ /usr/bin/wish8.5
    % font names
    systemPushButtonFont systemMenuItemFont systemApplicationFont systemSystemFont systemMenuItemMarkFont TkMenuFont TkDefaultFont systemSmallEmphasizedSystemFont systemDetailEmphasizedSystemFont systemMiniSystemFont TkHeadingFont TkTooltipFont systemUtilityWindowTitleFont systemViewsFont systemSmallSystemFont systemMenuTitleFont systemEmphasizedSystemFont TkTextFont systemDetailSystemFont TkCaptionFont systemLabelFont systemAlertHeaderFont systemMenuItemCmdKeyFont TkSmallCaptionFont TkFixedFont systemWindowTitleFont systemToolbarFont TkIconFont
    % font actual system
    -family {Lucida Grande} -size 13 -weight normal -slant roman -underline 0 -overstrike 0

    Based on the man page here (http://www.tcl.tk/man/tcl8.5/TkCmd/font.htm#M31) it appears any of the "standard" font names would be a better choice, like TkDefaultFont.

    Also, test_font should include the standard tkinter.test setUp and setDown functions so that the test can be run by itself.

    The attached patch should fix both issues.

    @ned-deily ned-deily changed the title [REGRESSION] test_tk broken on MacOSX 10.6 tkinter test_font fails on OS X with Aqua Tk Sep 20, 2010
    @pitrou
    Copy link
    Member

    pitrou commented Sep 20, 2010

    Patch works here (Mandriva Linux).

    @ned-deily
    Copy link
    Member

    Somebody want to commit it?

    @pitrou
    Copy link
    Member

    pitrou commented Sep 21, 2010

    Patch committed in r84952. Thanks!

    @pitrou pitrou closed this as completed Sep 21, 2010
    @pitrou
    Copy link
    Member

    pitrou commented Sep 26, 2010

    Actually, most buildbots were fixed but a couple of them still show a problem:

    test_font_eq (tkinter.test.test_tkinter.test_font.FontTest) ... ERROR
    testLoadTk (tkinter.test.test_tkinter.test_loadtk.TkLoadTest) ... skipped 'No $DISPLAY set.'
    testLoadTkFailure (tkinter.test.test_tkinter.test_loadtk.TkLoadTest) ... ok
    test_search (tkinter.test.test_tkinter.test_text.TextTest) ... ok

    ======================================================================
    ERROR: test_font_eq (tkinter.test.test_tkinter.test_font.FontTest)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/Users/db3l/buildarea/3.x.bolen-tiger/build/Lib/tkinter/test/test_tkinter/test_font.py", line 18, in test_font_eq
        font1 = font.nametofont("TkDefaultFont")
      File "/Users/db3l/buildarea/3.x.bolen-tiger/build/Lib/tkinter/font.py", line 22, in nametofont
        return Font(name=name, exists=True)
      File "/Users/db3l/buildarea/3.x.bolen-tiger/build/Lib/tkinter/font.py", line 83, in __init__
        "named font %s does not already exist" % (self.name,))
    _tkinter.TclError: named font TkDefaultFont does not already exist

    Intriguingly, when the test gets re-run at the end of the test suite, the test succeeds.
    Does it depend on another initialization that is done in another test file?

    @pitrou pitrou reopened this Sep 26, 2010
    @ned-deily
    Copy link
    Member

    Could be, particularly if the user name under which the test is running is not logged in (to the window manager) on the buildbot. I'll investigate.

    @ned-deily ned-deily self-assigned this Sep 26, 2010
    @ned-deily
    Copy link
    Member

    After further investigation, on OS X at least, there is a difference in behavior between Tk 8.4 (the system default on OS X 10.4 and 10.5) and Tk 8.5 (the default on 10.6). Lib/tkinter/font.py calls the Tk "font names" commands to check whether a font is already defined. At the point where test_font.py is initially run, there has not been any real Tk activity yet. For some reason, with 8.5 the system font names are returned; with 8.4 they are not:

    $ /usr/bin/wish8.4
    % font names
    $ /usr/bin/wish8.5
    % font names
    systemPushButtonFont systemMenuItemFont systemApplicationFont systemSystemFont systemMenuItemMarkFont TkMenuFont TkDefaultFont systemSmallEmphasizedSystemFont systemDetailEmphasizedSystemFont systemMiniSystemFont TkHeadingFont TkTooltipFont systemUtilityWindowTitleFont systemViewsFont systemSmallSystemFont systemMenuTitleFont systemEmphasizedSystemFont TkTextFont systemDetailSystemFont TkCaptionFont systemLabelFont systemAlertHeaderFont systemMenuItemCmdKeyFont TkSmallCaptionFont TkFixedFont systemWindowTitleFont systemToolbarFont TkIconFont

    So, a solution for that is to add a try block in test_font.py to create a font definition for TkDefaultFont if it does not already exist. (Presumably, after the test failed and before it was re-run, other tests ran which caused the fonts to be defined so it passes.) This time I have tested it with both Tk 8.4 and 8.5 on OS X 10.5 and 10.6. Additional patch file attached (to be applied on top of the already applied first patch).

    @ned-deily ned-deily removed their assignment Oct 5, 2010
    @pitrou
    Copy link
    Member

    pitrou commented Oct 5, 2010

    I've committed the patch in r85229. Let's see if this makes the buildbots happy.

    @pitrou
    Copy link
    Member

    pitrou commented Oct 5, 2010

    Looks alright, thank you!

    @pitrou pitrou closed this as completed Oct 5, 2010
    @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