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
Make idlelib.macosx self-contained. #71426
Comments
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. |
Here is a post-import patch with tests. |
New changeset cc7f63b6847e by Terry Jan Reedy in branch 'default': |
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? |
New changeset d8a2b6efdd4a by Terry Jan Reedy in branch 'default': |
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. |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: