New submission from Terry J. Reedy: 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. ---------- assignee: terry.reedy messages: 267513 nosy: terry.reedy priority: normal severity: normal stage: test needed status: open title: Make idlelib.macosx self-contained. type: behavior versions: Python 3.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27239> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com