]> granicus.if.org Git - python/commitdiff
Added tests for new signature of new.instance().
authorFred Drake <fdrake@acm.org>
Sun, 28 Jan 2001 03:57:39 +0000 (03:57 +0000)
committerFred Drake <fdrake@acm.org>
Sun, 28 Jan 2001 03:57:39 +0000 (03:57 +0000)
Use test_support.verify() where applicable.

Lib/test/test_new.py

index af26f01e6fca1a6054b5256dd1fa6bcfcbb6d987..30433aefb1f0dc605f0dd04e2fe51ea66d704c35 100644 (file)
@@ -1,4 +1,4 @@
-from test_support import verbose
+from test_support import verbose, verify
 import sys
 import new
 
@@ -25,6 +25,14 @@ print 'new.instance()'
 c = new.instance(C, {'yolks': 3})
 if verbose:
     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):
     self.yolks = self.yolks - 2
@@ -33,11 +41,11 @@ im = new.instancemethod(break_yolks, c, C)
 if verbose:
     print im
 
-if c.get_yolks() != 3 and c.get_more_yolks() != 6:
-    print 'Broken call of hand-crafted class instance'
+verify(c.get_yolks() == 3 and c.get_more_yolks() == 6,
+       'Broken call of hand-crafted class instance')
 im()
-if c.get_yolks() != 1 and c.get_more_yolks() != 4:
-    print 'Broken call of hand-crafted instance method'
+verify(c.get_yolks() == 1 and c.get_more_yolks() == 4,
+       'Broken call of hand-crafted instance method')
 
 codestr = '''
 a = 1
@@ -53,8 +61,8 @@ func = new.function(ccode, g)
 if verbose:
     print func
 func()
-if g['c'] != 3:
-    print 'Could not create a proper function object'
+verify(g['c'] == 3,
+       'Could not create a proper function object')
 
 # bogus test of new.code()
 print 'new.code()'