@@ -51,7 +51,7 @@ def test(self, case):
5151 if diff :
5252 msg += "\n " + diff .render_full ()
5353
54- case .failUnless (not diff , msg )
54+ case .assertTrue (not diff , msg )
5555
5656class TestNotEqual (object ):
5757 def __init__ (self , i1 , i2 , path = "" , actual = "" , expected = "" , name = "" ):
@@ -82,6 +82,12 @@ def test(self, case):
8282
8383class DeepTest (unittest .TestCase ):
8484 def runTest (self ):
85+ import sys
86+ if sys .version_info [0 ] == 2 :
87+ type_str = 'type'
88+ else :
89+ type_str = 'class'
90+
8591 tests = [E (1 , 1 , "1 == 1" ),
8692 N (1 , 2 , "x" , "1" , "2" , "1 != 2" ),
8793 E ((1 ,2 ), (1 ,2 ), "tuple diff" ),
@@ -93,16 +99,16 @@ def runTest(self):
9399 "[] ! Type int" ),
94100 E (self , d .InstanceOf (unittest .TestCase ), "self InstanceOf test" ),
95101 N ([], d .InstanceOf (int ), "x" ,
96- "instance of <type 'list'>" ,
97- "instance of <type 'int'>" ,
102+ "instance of <%s 'list'>" % type_str ,
103+ "instance of <%s 'int'>" % type_str ,
98104 "[] ! InstanceOf int" ),
99105 E ([0 ,1 ], d .IndexedElem (1 , 1 ), "List[1]" ),
100106 N ([0 ,1 ], d .IndexedElem (0 , 1 ), "x[0]" , "0" , "1" , "List[0]" ),
101107 E ([0 ,1 ], d .List ([0 , 1 ]), "list" ),
102108 N ([0 ,1 ], d .List ([0 , 0 ]), "x[1]" , "1" , "0" , "not list" ),
103109 E ([0 ,1 ], [0 , 1 ], "auto list" ),
104110 N ([0 ,1 ], d .List ([0 , 0 , 0 ]), "len(x)" , "2" , "3" , "not list len" ),
105- N (1 , d .List ([0 , 0 , 0 ]), "x" , "instance of <type 'int'>" , None , "not list type" ),
111+ N (1 , d .List ([0 , 0 , 0 ]), "x" , "instance of <%s 'int'>" % type_str , None , "not list type" ),
106112 E ([1 ,0 ], d .EqSet ([0 , 1 ]), "eqset" ),
107113 N ([0 ,1 ], d .EqSet ([0 , 2 ]), "x as a set (==)" ,
108114 "1 matching element(s), extra: [1], missing: [2]" ,
@@ -123,7 +129,7 @@ def runTest(self):
123129 N ({"a" : 0 , "c" : 1 }, d .Dict ({"a" : 1 , "b" : 1 }),
124130 'x.keys() as a set (==)' , None , None , "! Dict keys" ),
125131 N (1 , d .Dict ({"a" : 1 , "b" : 1 }),
126- 'x' , "instance of <type 'int'>" , None , "! Dict type" ),
132+ 'x' , "instance of <%s 'int'>" % type_str , None , "! Dict type" ),
127133 E ({"a" : 0 , "b" : 1 }, {"a" : 0 , "b" : 1 }, "auto Dict" ),
128134 E (o , d .HasAttr ("an_attr" ), "attr" ),
129135 N (o , d .HasAttr ("another_attr" ), "hasattr(x, 'another_attr')" , "False" , "True" , "! attr" ),
@@ -150,7 +156,7 @@ def runTest(self):
150156 N (o , d .And (d .Attr ("an_attr" , 1 ), d .Attr ("an_attr2" , 3 )), 'x.an_attr2' , "2" , "3" , "! and 2" ),
151157 E ([1 , 2 ], [d .Ignore (), 2 ], "ignore" ),
152158 E ("feRgal" , d .Re ("rga" , re .IGNORECASE ), "Re" ),
153- N ("feRgal" , d .Re ("rga" , re .MULTILINE ), "x" , ` "feRgal"` , "something matching 'rga' (flags=8)" , "Re" ),
159+ N ("feRgal" , d .Re ("rga" , re .MULTILINE ), "x" , repr ( "feRgal" ) , "something matching 'rga' (flags=8)" , "Re" ),
154160 E (["abc" , "ab" , "a" ], d .ArrayValues (d .Re ("a" )), "ArrayValues" ),
155161 N (["abc" , "ab" , "a" ], d .ArrayValues (d .Re ("b" )), "x[2]" , "a" .__repr__ (), "something matching 'b'" , "ArrayValues" ),
156162 E (["abc" , "ab" , "a" ],
@@ -187,8 +193,8 @@ def runTest(self):
187193 "2 matching element(s)" ,
188194 "not eqset" ),
189195 N ([0 ,1 ], set ([0 , 1 ]), "x as a set (==)" ,
190- "instance of <type 'list'>" ,
191- "instance of <type 'set'>" )
196+ "instance of <%s 'list'>" % type_str ,
197+ "instance of <%s 'set'>" % type_str )
192198 ])
193199
194200 if hasattr (__builtins__ , "frozenset" ):
@@ -199,8 +205,8 @@ def runTest(self):
199205 "2 matching element(s)" ,
200206 "not eqfrozenset" ),
201207 N ([0 ,1 ], frozenset ([0 , 1 ]), "x as a set (==)" ,
202- "instance of <type 'list'>" ,
203- "instance of <type 'frozenset'>" )
208+ "instance of <%s 'list'>" % type_str ,
209+ "instance of <%s 'frozenset'>" % type_str )
204210 ])
205211
206212 # for t in (tests[-1],):
@@ -215,7 +221,7 @@ def runTest(self):
215221 ex = None
216222 try :
217223 d .diff ([0 , 1 ], d .IndexedElem (2 , None ))
218- except Exception , e :
224+ except Exception as e :
219225 ex = e
220226
221227 for pat in (r"examining x\[2\]" , "IndexError" ):
0 commit comments