[issue21647] Idle unittests: make gui, mock switching easier.

Saimadhav Heblikar report at bugs.python.org
Fri Jun 6 12:52:28 CEST 2014


Saimadhav Heblikar added the comment:

Perhaps, we can move GUI/non GUI code into blocks. I will take Text as example. 

from test import support
if support._is_gui_available():
   from tkinter import Text
else:
   from idlelib.idle_test.mock_tk import Text
.
.
.
if not support._is_gui_available():
    parts of test which can be run keeping in mind mock.Text's      limitations.
else:
    everything, using tkinter.Text



Only drawback is _is_gui_available is not documented publicly. Also, we'd will have lot of if...else blocks all over the place. Avoiding code duplication will be tricky.
If nothing else, the if...else block can be used at the import level only.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21647>
_______________________________________


More information about the Python-bugs-list mailing list