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_setupapp (idlelib.idle_test.test_macosx.SetupTest) fails on OS X
Type: Stage: resolved
Components: IDLE Versions: Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: ned.deily, python-dev, terry.reedy
Priority: high Keywords:

Created on 2016-06-14 00:49 by ned.deily, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (7)
msg268492 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2016-06-14 00:49
Running tests of 3.6.0a2 with gui enabled on OS X result in various failures of the form:

======================================================================
ERROR: test_setupapp (idlelib.idle_test.test_macosx.SetupTest) (tktype='carbon')
Call setupApp with each possible graphics type.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/idlelib/idle_test/test_macosx.py", line 93, in test_setupapp
    macosx.setupApp(root, flist)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/idlelib/macosx.py", line 245, in setupApp
    overrideRootMenu(root, flist)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/idlelib/macosx.py", line 133, in overrideRootMenu
    closeItem = mainmenu.menudefs[0][1][-2]
IndexError: list index out of range

======================================================================
ERROR: test_setupapp (idlelib.idle_test.test_macosx.SetupTest) (tktype='cocoa')
Call setupApp with each possible graphics type.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/idlelib/idle_test/test_macosx.py", line 93, in test_setupapp
    macosx.setupApp(root, flist)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/idlelib/macosx.py", line 245, in setupApp
    overrideRootMenu(root, flist)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/idlelib/macosx.py", line 133, in overrideRootMenu
    closeItem = mainmenu.menudefs[0][1][-2]
IndexError: list index out of range
msg268493 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2016-06-14 00:54
Without looking closely at it, I would speculate that the failures are due to trying to test code in overrideRootMenu() that was previously only called once during execution and may not be re-enterant:

    # Remove the last 3 items of the file menu: a separator, close window and
    # quit. Close window will be reinserted just above the save item, where
    # it should be according to the HIG. Quit is in the application menu.
    del mainmenu.menudefs[0][1][-3:]
    mainmenu.menudefs[0][1].insert(6, closeItem)
msg268503 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-06-14 02:38
test_setupapp calls setupApp with body 
    if isAquaTk():
        hideTkConsole(root)
        overrideRootMenu(root, flist)
        addOpenEventSupport(root, flist)
        fixb2context(root)
isAquaTk should be True exactly twice, and it failed both times.  The overall code is definitely not re-entrant  On Carbon, 'application' in inserted before 'file' and becomes menudef[0].  The puzzle to me is the failure on what should be the first call.

Until that is figured out, you could try decorating test_setupapp with
    @mock.patch(idlelib.macosx.setupApp)
to see what, if anything, fails next.

I have access to a small Macbook Air with 11" diag. screen -- probably too small for my eyes for routine use but I should be able to run test_idle (especially post push) and do occasional exploratory editing, as needed here.  I will try to learn enough about how to use it to follow the devguide instructions on setting up a repository.
msg268747 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-06-17 23:56
New changeset 90fd1c17214b by Terry Jan Reedy in branch 'default':
Issue #27312: mock out function that fails when called from setupApp during
https://hg.python.org/cpython/rev/90fd1c17214b
msg268748 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-06-17 23:57
My suggested mock was for the wrong function.  Please let me know what happens next time you pull and run test_idle whether alone or with the suite.
msg268751 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-06-18 01:17
New changeset 61bd6974405f by Berker Peksag in branch 'default':
Issue #27312: Fix TypeError in test_setupapp
https://hg.python.org/cpython/rev/61bd6974405f
msg268836 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2016-06-19 03:08
test_idle now runs without failing.  Thanks, Terry and Berker.
History
Date User Action Args
2022-04-11 14:58:32adminsetgithub: 71499
2016-06-19 03:08:14ned.deilysetstatus: open -> closed
resolution: fixed
messages: + msg268836

stage: needs patch -> resolved
2016-06-18 01:17:46python-devsetmessages: + msg268751
2016-06-17 23:57:55terry.reedysetmessages: + msg268748
2016-06-17 23:56:14python-devsetnosy: + python-dev
messages: + msg268747
2016-06-14 02:38:50terry.reedysetmessages: + msg268503
2016-06-14 00:54:07ned.deilysetmessages: + msg268493
2016-06-14 00:49:50ned.deilycreate