Skip to content
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

IDle: test textView.py #63110

Closed
philwebster mannequin opened this issue Sep 3, 2013 · 13 comments
Closed

IDle: test textView.py #63110

philwebster mannequin opened this issue Sep 3, 2013 · 13 comments
Assignees
Labels
topic-IDLE type-feature A feature request or enhancement

Comments

@philwebster
Copy link
Mannequin

philwebster mannequin commented Sep 3, 2013

BPO 18910
Nosy @terryjreedy, @ned-deily, @rovitotv, @zware, @serhiy-storchaka
Files
  • test_textview.patch
  • test_textview-18910.patch
  • 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:

    assignee = 'https://github.com/terryjreedy'
    closed_at = <Date 2016-05-16.04:08:06.158>
    created_at = <Date 2013-09-03.01:56:46.289>
    labels = ['expert-IDLE', 'type-feature']
    title = 'IDle: test textView.py'
    updated_at = <Date 2016-05-16.04:08:06.112>
    user = 'https://bugs.python.org/philwebster'

    bugs.python.org fields:

    activity = <Date 2016-05-16.04:08:06.112>
    actor = 'terry.reedy'
    assignee = 'terry.reedy'
    closed = True
    closed_date = <Date 2016-05-16.04:08:06.158>
    closer = 'terry.reedy'
    components = ['IDLE']
    creation = <Date 2013-09-03.01:56:46.289>
    creator = 'philwebster'
    dependencies = []
    files = ['31569', '35488']
    hgrepos = []
    issue_num = 18910
    keywords = ['patch']
    message_count = 13.0
    messages = ['196820', '219782', '219784', '219899', '219900', '219921', '219923', '219925', '220009', '220041', '220073', '265664', '265665']
    nosy_count = 9.0
    nosy_names = ['terry.reedy', 'ned.deily', 'Todd.Rovito', 'python-dev', 'zach.ware', 'serhiy.storchaka', 'JayKrish', 'philwebster', 'Saimadhav.Heblikar']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue18910'
    versions = ['Python 2.7', 'Python 3.4', 'Python 3.5', 'Python 3.6']

    @philwebster
    Copy link
    Mannequin Author

    philwebster mannequin commented Sep 3, 2013

    Started writing the tests for textView.py.

    @philwebster philwebster mannequin added topic-IDLE type-feature A feature request or enhancement labels Sep 3, 2013
    @terryjreedy terryjreedy changed the title IDLE: Unit test for textView.py IDle: test textView.py Jun 1, 2014
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jun 5, 2014

    New changeset 9ac57970ee4c by Terry Jan Reedy in branch '2.7':
    Issue bpo-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 bpo-18910: Add unittest for textView. Patch by Phil Webster.
    http://hg.python.org/cpython/rev/99047f3a19a9

    @terryjreedy
    Copy link
    Member

    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.

    @terryjreedy
    Copy link
    Member

    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'.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jun 6, 2014

    New changeset 86ba41b7bb46 by Terry Jan Reedy in branch '2.7':
    Issue bpo-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 bpo-18910: test_textView - since all tests require 'gui', make root global.
    http://hg.python.org/cpython/rev/5a46ebfa5d90

    @ned-deily
    Copy link
    Member

    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

    @ned-deily ned-deily reopened this Jun 7, 2014
    @serhiy-storchaka
    Copy link
    Member

    Please don't create Tk object at module creating stage. I afraid this will break unittest discoverity.

    @terryjreedy
    Copy link
    Member

    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.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jun 8, 2014

    New changeset a0be81607a50 by Benjamin Peterson in branch '2.7':
    backed out 86ba41b7bb46 (bpo-18910) for test breakage
    http://hg.python.org/cpython/rev/a0be81607a50

    @zware
    Copy link
    Member

    zware commented Jun 8, 2014

    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.

    @terryjreedy
    Copy link
    Member

    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.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 16, 2016

    New changeset f5e20abea871 by Terry Jan Reedy in branch '2.7':
    bpo-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':
    bpo-18910: Edit idle_test/README.txt to add 'requires' usage at module scope.
    https://hg.python.org/cpython/rev/735eebce6765

    @terryjreedy
    Copy link
    Member

    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.

    @terryjreedy terryjreedy self-assigned this May 16, 2016
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    topic-IDLE type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants