@@ -21,7 +21,9 @@ def __init__(self, *args, **kwargs):
2121 'add' : '+' ,
2222 'sub' : '-' ,
2323 'mul' : '*' ,
24- 'div' : '/' ,
24+ 'matmul' : '@' ,
25+ 'truediv' : '/' ,
26+ 'floordiv' : '//' ,
2527 'divmod' : 'divmod' ,
2628 'pow' : '**' ,
2729 'lshift' : '<<' ,
@@ -52,8 +54,6 @@ def __init__(self, *args, **kwargs):
5254 'invert' : '~' ,
5355 'int' : 'int' ,
5456 'float' : 'float' ,
55- 'oct' : 'oct' ,
56- 'hex' : 'hex' ,
5757 }
5858
5959 for name , expr in list (self .unops .items ()):
@@ -82,12 +82,6 @@ def unop_test(self, a, res, expr="len(a)", meth="__len__"):
8282 def binop_test (self , a , b , res , expr = "a+b" , meth = "__add__" ):
8383 d = {'a' : a , 'b' : b }
8484
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-
9185 self .assertEqual (eval (expr , d ), res )
9286 t = type (a )
9387 m = getattr (t , meth )
@@ -221,7 +215,7 @@ def test_dicts(self):
221215 def number_operators (self , a , b , skip = []):
222216 dict = {'a' : a , 'b' : b }
223217
224- for name , expr in list ( self .binops .items () ):
218+ for name , expr in self .binops .items ():
225219 if name not in skip :
226220 name = "__%s__" % name
227221 if hasattr (a , name ):
@@ -261,7 +255,7 @@ def test_complexes(self):
261255 # Testing complex operations...
262256 self .number_operators (100.0j , 3.0j , skip = ['lt' , 'le' , 'gt' , 'ge' ,
263257 'int' , 'float' ,
264- 'divmod' , 'mod' ])
258+ 'floordiv' , ' divmod' , 'mod' ])
265259
266260 class Number (complex ):
267261 __slots__ = ['prec' ]
@@ -4177,9 +4171,8 @@ def check(expr, x, y):
41774171 ('__sub__' , 'x - y' , 'x -= y' ),
41784172 ('__mul__' , 'x * y' , 'x *= y' ),
41794173 ('__matmul__' , 'x @ y' , 'x @= y' ),
4180- ('__truediv__' , 'operator.truediv(x, y)' , None ),
4181- ('__floordiv__' , 'operator.floordiv(x, y)' , None ),
4182- ('__div__' , 'x / y' , 'x /= y' ),
4174+ ('__truediv__' , 'x / y' , 'x /= y' ),
4175+ ('__floordiv__' , 'x // y' , 'x //= y' ),
41834176 ('__mod__' , 'x % y' , 'x %= y' ),
41844177 ('__divmod__' , 'divmod(x, y)' , None ),
41854178 ('__pow__' , 'x ** y' , 'x **= y' ),
@@ -4241,8 +4234,8 @@ class X(object):
42414234 # Also check type_getattro for correctness.
42424235 class Meta (type ):
42434236 pass
4244- class X (object ):
4245- __metaclass__ = Meta
4237+ class X (metaclass = Meta ):
4238+ pass
42464239 X .a = 42
42474240 Meta .a = Descr ("a" )
42484241 self .assertEqual (X .a , 42 )
0 commit comments