Turn three recently fixed crashers into regular tests.

This commit is contained in:
Guido van Rossum 2008-01-23 23:23:43 +00:00
parent f30ba3dd66
commit 9acc387bcf
1 changed files with 70 additions and 1 deletions

View File

@ -1,5 +1,7 @@
# Test enhancements related to descriptors and new-style classes
# XXX Please, please, please, someone convert this to unittest style!
from test.test_support import verify, vereq, verbose, TestFailed, TESTFN, get_original_stdout
from copy import deepcopy
import warnings
@ -4427,6 +4429,8 @@ def test_assign_slice():
# ceval.c's assign_slice used to check for
# tp->tp_as_sequence->sq_slice instead of
# tp->tp_as_sequence->sq_ass_slice
if verbose:
print "Testing assign_slice..."
class C(object):
def __setslice__(self, start, stop, value):
@ -4436,8 +4440,70 @@ def test_assign_slice():
c[1:2] = 3
vereq(c.value, 3)
def test_weakref_in_del_segfault():
# This used to segfault until r60057
if verbose:
print "Testing weakref in del segfault..."
import weakref
global ref
class Target():
def __del__(self):
global ref
ref = weakref.ref(self)
w = Target()
del w
del ref
def test_borrowed_ref_3_segfault():
# This used to segfault until r60224
if verbose:
print "Testing borrowed ref 3 segfault..."
class KeyFunc(object):
def __call__(self, n):
del d['key']
return 1
d = {'key': KeyFunc()}
try:
min(range(10), **d)
except:
pass
def test_borrowed_ref_4_segfault():
# This used to segfault until r60224
if verbose:
print "Testing borrowed ref 4 segfault..."
import types
import __builtin__
class X(object):
def __getattr__(self, name):
# this is called with name == '__bases__' by PyObject_IsInstance()
# during the unbound method call -- it frees the unbound method
# itself before it invokes its im_func.
del __builtin__.__import__
return ()
pseudoclass = X()
class Y(object):
def __call__(self, *args):
# 'self' was freed already
return (self, args)
# make an unbound method
__builtin__.__import__ = types.MethodType(Y(), None, (pseudoclass, str))
import spam
def test_main():
weakref_segfault() # Must be first, somehow
#XXXweakref_segfault() # Must be first, somehow
wrapper_segfault()
do_this_first()
class_docstrings()
@ -4535,6 +4601,9 @@ def test_main():
methodwrapper()
notimplemented()
test_assign_slice()
test_weakref_in_del_segfault()
test_borrowed_ref_3_segfault()
test_borrowed_ref_4_segfault()
if verbose: print "All OK"