1 from test_support
import verbose
10 m
= new
.module('Spam')
14 sys
.modules
['Spam'] = m
17 def get_more_yolks(self
):
20 print 'new.classobj()'
21 C
= new
.classobj('Spam', (Spam
.Eggs
,), {'get_more_yolks': get_more_yolks
})
24 print 'new.instance()'
25 c
= new
.instance(C
, {'yolks': 3})
29 def break_yolks(self
):
30 self
.yolks
= self
.yolks
- 2
31 print 'new.instancemethod()'
32 im
= new
.instancemethod(break_yolks
, c
, C
)
36 if c
.get_yolks() <> 3 and c
.get_more_yolks() <> 6:
37 print 'Broken call of hand-crafted class instance'
39 if c
.get_yolks() <> 1 and c
.get_more_yolks() <> 4:
40 print 'Broken call of hand-crafted instance method'
48 ccode
= compile(codestr
, '<string>', 'exec')
49 g
= {'c': 0, '__builtins__': __builtins__
}
50 # this test could be more robust
51 print 'new.function()'
52 func
= new
.function(ccode
, g
)
57 print 'Could not create a proper function object'
59 # bogus test of new.code()
61 d
= new
.code(3, 3, 3, 3, codestr
, (), (), (), "<string>", "<name>", 1, "")