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: IDle: test textView.py
Type: enhancement Stage: resolved
Components: IDLE Versions: Python 3.6, Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: JayKrish, Saimadhav.Heblikar, Todd.Rovito, ned.deily, philwebster, python-dev, serhiy.storchaka, terry.reedy, zach.ware
Priority: normal Keywords: patch

Created on 2013-09-03 01:56 by philwebster, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test_textview.patch philwebster, 2013-09-03 01:56 review
test_textview-18910.patch terry.reedy, 2014-06-05 08:03 review
Messages (13)
msg196820 - (view) Author: Phil Webster (philwebster) * Date: 2013-09-03 01:56
Started writing the tests for textView.py.
msg219782 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-06-05 07:54
New changeset 9ac57970ee4c by Terry Jan Reedy in branch '2.7':
Issue #18910: Add unittest for textView. Patch by Phil Webster.
http://hg.python.org/cpython/rev/9ac57970ee4c

New changeset 99047f3a19a9 by Terry Jan Reedy in branch '3.4':
Issue #18910: Add unittest for textView. Patch by Phil Webster.
http://hg.python.org/cpython/rev/99047f3a19a9
msg219784 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-06-05 08:03
The use of .__new__ was cute. Unfortunately, it did not backport to 2.7 because tkinter classes were never upgraded from old to new in 2.7 and old-style classes do not have .__new__. So I monkeypatched the module instead, which is a but clumbsier than patching the instance.
Though not every detail is tested, coverage is essentialy 100% and the human text covers the visual details.
msg219899 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-06-06 21:43
Since all tests create a widget with widgets (or destroy it), the new patch moves root to class scope and simplifies the code a bit. It also subclasses TextViewer instead of monkey-patching it. Modules have to be monkey-patched because they cannot be 'sub-moduled'.
msg219900 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-06-06 21:44
New changeset 86ba41b7bb46 by Terry Jan Reedy in branch '2.7':
Issue #18910: test_textView - since all tests require 'gui', make root global.
http://hg.python.org/cpython/rev/86ba41b7bb46

New changeset 5a46ebfa5d90 by Terry Jan Reedy in branch '3.4':
Issue #18910: test_textView - since all tests require 'gui', make root global.
http://hg.python.org/cpython/rev/5a46ebfa5d90
msg219921 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2014-06-07 07:45
It looks like the 2.7 checkin has caused a number of buildbots to fail.  Examples:

http://buildbot.python.org/all/builders/AMD64%20Ubuntu%20LTS%202.7/builds/1094/steps/test/logs/stdio

======================================================================
ERROR: idlelib.idle_test.test_textview (unittest.loader.ModuleImportFailure)
----------------------------------------------------------------------
ImportError: Failed to import test module: idlelib.idle_test.test_textview
Traceback (most recent call last):
  File "/opt/python/2.7.langa-ubuntu/build/Lib/unittest/loader.py", line 254, in _find_tests
    module = self._get_module_from_name(name)
  File "/opt/python/2.7.langa-ubuntu/build/Lib/unittest/loader.py", line 232, in _get_module_from_name
    __import__(name)
  File "/opt/python/2.7.langa-ubuntu/build/Lib/idlelib/idle_test/test_textview.py", line 11, in <module>
    requires('gui')
  File "/opt/python/2.7.langa-ubuntu/build/Lib/test/test_support.py", line 359, in requires
    raise ResourceDenied(_is_gui_available.reason)
ResourceDenied: Tk unavailable due to TclError: no display name and no $DISPLAY environment variab [...]

and:

http://buildbot.python.org/all/builders/AMD64%20Snow%20Leop%202.7/builds/440/steps/test/logs/stdio

======================================================================
ERROR: idlelib.idle_test.test_textview (unittest.loader.ModuleImportFailure)
----------------------------------------------------------------------
ImportError: Failed to import test module: idlelib.idle_test.test_textview
Traceback (most recent call last):
  File "/Users/buildbot/buildarea/2.7.murray-snowleopard/build/Lib/unittest/loader.py", line 254, in _find_tests
    module = self._get_module_from_name(name)
  File "/Users/buildbot/buildarea/2.7.murray-snowleopard/build/Lib/unittest/loader.py", line 232, in _get_module_from_name
    __import__(name)
  File "/Users/buildbot/buildarea/2.7.murray-snowleopard/build/Lib/idlelib/idle_test/test_textview.py", line 11, in <module>
    requires('gui')
  File "/Users/buildbot/buildarea/2.7.murray-snowleopard/build/Lib/test/test_support.py", line 359, in requires
    raise ResourceDenied(_is_gui_available.reason)
ResourceDenied: gui tests cannot run without OS X window manager
msg219923 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-06-07 08:32
Please don't create Tk object at module creating stage. I afraid this will break unittest discoverity.
msg219925 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-06-07 09:23
The 3.4 stable buildbots are green except for two that ran test_idle ok.
The problem is that in 2.7, unittest.loader does not catch ResourceDenied at module level whereas is does in 3.4. The only indication that there should be a difference is that the 3.x doc has "Skipped modules will not have setUpModule() or tearDownModule() run."

I am puzzled though, since the manual says this was added in 3.1 and 2.7 came out after. Also, I presume that 2.7 test.regrtest honors the SkipTest raised by 2.7 test_support.import_module, which is usually used at module level. 

If someone wants to revert the patch, go ahead. I have to get some sleep before I do anything (it is 5 am).
--

"Please don't create Tk object at module creating stage."
I didn't. I intentionally put TK stuff inside setUpModule so it would happen at test running stage.
msg220009 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-06-08 00:57
New changeset a0be81607a50 by Benjamin Peterson in branch '2.7':
backed out 86ba41b7bb46 (#18910) for test breakage
http://hg.python.org/cpython/rev/a0be81607a50
msg220041 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2014-06-08 18:49
The changeset Benjamin backed out is pretty much fine, just needs the requires('gui') to be at the top of setUpModule instead of at toplevel.  That does mean the whole module is constructed and then thrown away without doing anything, but it at least runs properly even with no Tk available.
msg220073 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-06-09 00:07
Yes, early skipping was the reason I put the test where I did. The simple change occurred to me today. I have not decided yet whether to also change the 3.4/5 files to match and how to edit the testing README. For one test, I would not care either way. But I expect there to be more files with the same issue, So I wonder what is the best way to avoid hitting the same booby trap again.
msg265664 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-05-16 03:53
New changeset f5e20abea871 by Terry Jan Reedy in branch '2.7':
Issue 18910: Edit idle_test/README.txt to add 'requires' warning.
https://hg.python.org/cpython/rev/f5e20abea871

New changeset 735eebce6765 by Terry Jan Reedy in branch '3.5':
Issue 18910: Edit idle_test/README.txt to add 'requires' usage at module scope.
https://hg.python.org/cpython/rev/735eebce6765
msg265665 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-05-16 04:08
I have stopped patching IDLE for 2.7 and will not add more tests.  So there is no reason to constrain tests for 3.5, and soon 3.6, to 2.7 limitations.
History
Date User Action Args
2022-04-11 14:57:50adminsetgithub: 63110
2016-05-16 04:08:06terry.reedysetstatus: open -> closed
versions: + Python 3.6
messages: + msg265665

assignee: terry.reedy
resolution: fixed
stage: needs patch -> resolved
2016-05-16 03:53:33python-devsetmessages: + msg265664
2014-06-09 00:07:59terry.reedysetmessages: + msg220073
2014-06-08 18:49:52zach.waresetmessages: + msg220041
2014-06-08 00:57:41python-devsetmessages: + msg220009
2014-06-07 09:23:14terry.reedysetmessages: + msg219925
2014-06-07 08:32:43serhiy.storchakasetnosy: + zach.ware
2014-06-07 08:32:05serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg219923
2014-06-07 07:45:40ned.deilysetstatus: closed -> open

nosy: + ned.deily
messages: + msg219921

resolution: fixed -> (no value)
stage: resolved -> needs patch
2014-06-06 21:44:05python-devsetmessages: + msg219900
2014-06-06 21:43:15terry.reedysetnosy: + Saimadhav.Heblikar
messages: + msg219899
2014-06-05 08:03:37terry.reedysetstatus: open -> closed
files: + test_textview-18910.patch
messages: + msg219784

resolution: fixed
stage: patch review -> resolved
2014-06-05 07:54:52python-devsetnosy: + python-dev
messages: + msg219782
2014-06-01 22:11:26terry.reedysettitle: IDLE: Unit test for textView.py -> IDle: test textView.py
stage: patch review
versions: + Python 3.5, - Python 3.3
2013-09-03 01:56:46philwebstercreate