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: Make idlelib.macosx self-contained.
Type: behavior Stage: resolved
Components: IDLE Versions: Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: terry.reedy
Priority: normal Keywords: patch

Created on 2016-06-06 02:57 by terry.reedy, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
macosx-contained.diff terry.reedy, 2016-06-06 22:02 review
Messages (6)
msg267513 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-06-06 02:57
Lib/idlelib/macosx.py:8 initializes _tk_type to None.  It next defines private function _initializeTkVariantTests, which in called in setupApp and which initializes _tk_type.  Then follow 4 isXyzTk functins, which "assert _tk_type is not None".  This is fine for IDLE because IDLE call setupApp on startup.

This is not fine for testing.  In general, tests do not and should not call setupApp. If a test happens to exercise one of the 11 (for now) isXyzTk calls occurring outside of macosx, the assert is triggered.  The test writer must then discover to import and call the supposedly private _initializeTkVariantTests.

I would prefer instead that maxosx be more self-contained, and initialize _tk_type as needed.  _initializeTkVariantTests needs a Tk instance for this line.
        ws = root.tk.call('tk', 'windowingsystem')
I would like to wrap that with root = tkinter.Tk() and root.destroy.  If that cannot be done on import, then instead of deleting the asserts, replace them with conditional calls to the initialization function.
msg267564 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-06-06 22:02
Here is a post-import patch with tests.
msg267908 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-06-08 22:09
New changeset cc7f63b6847e by Terry Jan Reedy in branch 'default':
Issue #27239: idlelib.macosx.isXyzTk functions initialize as needed.
https://hg.python.org/cpython/rev/cc7f63b6847e
msg267911 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-06-08 22:17
I ran into this issue again with the test I am writing for another issue, so I pushed it as is, after testing.

Ned, neither of the working OSX buildbots run gui tests.  I am presuming that you run the test suite occasionally and will notice if test_idle fails.

Serhiy, almost ditto, except for Zach Ware's Gentoo bot.  What do you think of initializing, using a temporary Tk(), during import?  Or best to leave as is?
msg268396 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-06-12 19:49
New changeset d8a2b6efdd4a by Terry Jan Reedy in branch 'default':
Issue #27239: Continue refactoring idlelib.macosx and adding macosx tests.
https://hg.python.org/cpython/rev/d8a2b6efdd4a
msg268397 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-06-12 19:50
Remove the now unneeded call in htest to _init_tk_type.  It was tempting to leave the call for the 'efficiency' of the direct call with the available root, but there is a mental efficiency in removing it and making _init_tk_type completely an internal implementation detail of macosx.

Remove the unneeded call in macosx.setupApp.  This makes the _init_tk_type local to its section of the module.  It also allows a test to set _tk_type to simulate being on a particular type of Mac and call setupApp without having the setting overwritten by the real value. Test_macosx now calls setupApp with each _tk_type set to each possible non-None value.

The same objective could have been met by conditioning the call with 'if _tk_type is  None:', but removing the call means that _init_tk_type is no longer ever called with a root, so the parameter can be removed and the function simplified.  This section of macosx now takes care of initializing itself and the rest of IDLE can simply call the isTypeTk functions without worrying about initialization.

Have macosx call its test when run as main.
History
Date User Action Args
2022-04-11 14:58:32adminsetgithub: 71426
2019-03-21 18:18:46terry.reedysetnosy: - python-dev
components: + IDLE
2016-06-12 19:50:23terry.reedysetmessages: + msg268397
2016-06-12 19:49:48python-devsetmessages: + msg268396
2016-06-10 04:18:16terry.reedysetstatus: open -> closed
stage: needs patch -> resolved
2016-06-08 22:17:33terry.reedysetresolution: fixed
messages: + msg267911
stage: patch review -> needs patch
2016-06-08 22:09:44python-devsetnosy: + python-dev
messages: + msg267908
2016-06-06 22:02:59terry.reedysetfiles: + macosx-contained.diff
keywords: + patch
messages: + msg267564

stage: test needed -> patch review
2016-06-06 02:57:34terry.reedycreate