@@ -21,7 +21,8 @@ def __init__(self, *args, **kwargs):
2121 'add' : '+' ,
2222 'sub' : '-' ,
2323 'mul' : '*' ,
24- 'div' : '/' ,
24+ 'truediv' : '/' ,
25+ 'floordiv' : '//' ,
2526 'divmod' : 'divmod' ,
2627 'pow' : '**' ,
2728 'lshift' : '<<' ,
@@ -52,8 +53,6 @@ def __init__(self, *args, **kwargs):
5253 'invert' : '~' ,
5354 'int' : 'int' ,
5455 'float' : 'float' ,
55- 'oct' : 'oct' ,
56- 'hex' : 'hex' ,
5756 }
5857
5958 for name , expr in list (self .unops .items ()):
@@ -82,12 +81,6 @@ def unop_test(self, a, res, expr="len(a)", meth="__len__"):
8281 def binop_test (self , a , b , res , expr = "a+b" , meth = "__add__" ):
8382 d = {'a' : a , 'b' : b }
8483
85- # XXX Hack so this passes before 2.3 when -Qnew is specified.
86- if meth == "__div__" and 1 / 2 == 0.5 :
87- meth = "__truediv__"
88-
89- if meth == '__divmod__' : pass
90-
9184 self .assertEqual (eval (expr , d ), res )
9285 t = type (a )
9386 m = getattr (t , meth )
@@ -221,7 +214,7 @@ def test_dicts(self):
221214 def number_operators (self , a , b , skip = []):
222215 dict = {'a' : a , 'b' : b }
223216
224- for name , expr in list ( self .binops .items () ):
217+ for name , expr in self .binops .items ():
225218 if name not in skip :
226219 name = "__%s__" % name
227220 if hasattr (a , name ):
@@ -261,7 +254,7 @@ def test_complexes(self):
261254 # Testing complex operations...
262255 self .number_operators (100.0j , 3.0j , skip = ['lt' , 'le' , 'gt' , 'ge' ,
263256 'int' , 'float' ,
264- 'divmod' , 'mod' ])
257+ 'floordiv' , ' divmod' , 'mod' ])
265258
266259 class Number (complex ):
267260 __slots__ = ['prec' ]
@@ -4160,9 +4153,8 @@ def check(expr, x, y):
41604153 ('__add__' , 'x + y' , 'x += y' ),
41614154 ('__sub__' , 'x - y' , 'x -= y' ),
41624155 ('__mul__' , 'x * y' , 'x *= y' ),
4163- ('__truediv__' , 'operator.truediv(x, y)' , None ),
4164- ('__floordiv__' , 'operator.floordiv(x, y)' , None ),
4165- ('__div__' , 'x / y' , 'x /= y' ),
4156+ ('__truediv__' , 'x / y' , 'x /= y' ),
4157+ ('__floordiv__' , 'x // y' , 'x //= y' ),
41664158 ('__mod__' , 'x % y' , 'x %= y' ),
41674159 ('__divmod__' , 'divmod(x, y)' , None ),
41684160 ('__pow__' , 'x ** y' , 'x **= y' ),
@@ -4224,8 +4216,8 @@ class X(object):
42244216 # Also check type_getattro for correctness.
42254217 class Meta (type ):
42264218 pass
4227- class X (object ):
4228- __metaclass__ = Meta
4219+ class X (metaclass = Meta ):
4220+ pass
42294221 X .a = 42
42304222 Meta .a = Descr ("a" )
42314223 self .assertEqual (X .a , 42 )
0 commit comments