Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Lib/test/test_curses.py

    r2 r391  
    1010#
    1111
    12 import curses, sys, tempfile, os
    13 import curses.panel
     12import sys, tempfile, os
    1413
    1514# Optionally test curses module.  This currently requires that the
     
    1716# option.  If not available, nothing after this line will be executed.
    1817
    19 from test.test_support import requires, TestSkipped
     18import unittest
     19from test.test_support import requires, import_module
    2020requires('curses')
    21 
    22 # skip all these tests on FreeBSD: test_curses currently hangs the
    23 # FreeBSD buildbots, preventing other tests from running.  See issue
    24 # #7384.
    25 if 'freebsd' in sys.platform:
    26     raise unittest.SkipTest('The curses module is broken on FreeBSD.  See http://bugs.python.org/issue7384.')
     21curses = import_module('curses')
     22curses.panel = import_module('curses.panel')
     23
    2724
    2825# XXX: if newterm was supported we could use it instead of initscr and not exit
    2926term = os.environ.get('TERM')
    3027if not term or term == 'unknown':
    31     raise TestSkipped, "$TERM=%r, calling initscr() may cause exit" % term
     28    raise unittest.SkipTest, "$TERM=%r, calling initscr() may cause exit" % term
    3229
    3330if sys.platform == "cygwin":
    34     raise TestSkipped("cygwin's curses mostly just hangs")
     31    raise unittest.SkipTest("cygwin's curses mostly just hangs")
    3532
    3633def window_funcs(stdscr):
     
    222219            curses.mouseinterval(10)
    223220            # just verify these don't cause errors
     221            curses.ungetmouse(0, 0, 0, 0, curses.BUTTON1_PRESSED)
    224222            m = curses.getmouse()
    225             curses.ungetmouse(*m)
    226223
    227224    if hasattr(curses, 'is_term_resized'):
     
    254251        pass
    255252
     253def test_userptr_memory_leak(stdscr):
     254    w = curses.newwin(10, 10)
     255    p = curses.panel.new_panel(w)
     256    obj = object()
     257    nrefs = sys.getrefcount(obj)
     258    for i in range(100):
     259        p.set_userptr(obj)
     260
     261    p.set_userptr(None)
     262    if sys.getrefcount(obj) != nrefs:
     263        raise RuntimeError, "set_userptr leaked references"
     264
     265def test_userptr_segfault(stdscr):
     266    panel = curses.panel.new_panel(stdscr)
     267    class A:
     268        def __del__(self):
     269            panel.set_userptr(None)
     270    panel.set_userptr(A())
     271    panel.set_userptr(None)
     272
    256273def test_resize_term(stdscr):
    257274    if hasattr(curses, 'resizeterm'):
     
    272289        window_funcs(stdscr)
    273290        test_userptr_without_set(stdscr)
     291        test_userptr_memory_leak(stdscr)
     292        test_userptr_segfault(stdscr)
    274293        test_resize_term(stdscr)
    275294        test_issue6243(stdscr)
     
    282301else:
    283302    if not sys.__stdout__.isatty():
    284         raise TestSkipped("sys.__stdout__ is not a tty")
     303        raise unittest.SkipTest("sys.__stdout__ is not a tty")
    285304    # testing setupterm() inside initscr/endwin
    286305    # causes terminal breakage
Note: See TracChangeset for help on using the changeset viewer.