Added tests for new signature of new.instance().

Use test_support.verify() where applicable.
This commit is contained in:
Fred Drake 2001-01-28 03:57:39 +00:00
parent ceb2bff09e
commit 64d42c5bb1
1 changed files with 15 additions and 7 deletions

View File

@ -1,4 +1,4 @@
from test_support import verbose from test_support import verbose, verify
import sys import sys
import new import new
@ -25,6 +25,14 @@ print 'new.instance()'
c = new.instance(C, {'yolks': 3}) c = new.instance(C, {'yolks': 3})
if verbose: if verbose:
print c print c
o = new.instance(C)
verify(o.__dict__ == {},
"new __dict__ should be empty")
del o
o = new.instance(C, None)
verify(o.__dict__ == {},
"new __dict__ should be empty")
del o
def break_yolks(self): def break_yolks(self):
self.yolks = self.yolks - 2 self.yolks = self.yolks - 2
@ -33,11 +41,11 @@ im = new.instancemethod(break_yolks, c, C)
if verbose: if verbose:
print im print im
if c.get_yolks() != 3 and c.get_more_yolks() != 6: verify(c.get_yolks() == 3 and c.get_more_yolks() == 6,
print 'Broken call of hand-crafted class instance' 'Broken call of hand-crafted class instance')
im() im()
if c.get_yolks() != 1 and c.get_more_yolks() != 4: verify(c.get_yolks() == 1 and c.get_more_yolks() == 4,
print 'Broken call of hand-crafted instance method' 'Broken call of hand-crafted instance method')
codestr = ''' codestr = '''
a = 1 a = 1
@ -53,8 +61,8 @@ func = new.function(ccode, g)
if verbose: if verbose:
print func print func
func() func()
if g['c'] != 3: verify(g['c'] == 3,
print 'Could not create a proper function object' 'Could not create a proper function object')
# bogus test of new.code() # bogus test of new.code()
print 'new.code()' print 'new.code()'