[pypy-commit] pypy py3k: Merged.

prestontimmons noreply at buildbot.pypy.org
Wed Mar 14 19:34:39 CET 2012


Author: Preston Timmons <prestontimmons at gmail.com>
Branch: py3k
Changeset: r53568:43adfe9796b8
Date: 2012-03-13 18:15 +0000
http://bitbucket.org/pypy/pypy/changeset/43adfe9796b8/

Log:	Merged.

diff --git a/pypy/interpreter/test/test_interpreter.py b/pypy/interpreter/test/test_interpreter.py
--- a/pypy/interpreter/test/test_interpreter.py
+++ b/pypy/interpreter/test/test_interpreter.py
@@ -183,14 +183,10 @@
                 r = [
                     f(n, *[]),
                     f(n),
-                    apply(f, (n,)),
-                    apply(f, [n]),
                     f(*(n,)),
                     f(*[n]),
                     f(n=n),
                     f(**{'n': n}),
-                    apply(f, (n,), {}),
-                    apply(f, [n], {}),
                     f(*(n,), **{}),
                     f(*[n], **{}),
                     f(n, **{}),
@@ -203,7 +199,7 @@
                     ]
                 return r
             '''
-        assert self.codetest(code, 'f38', [117]) == [234]*19
+        assert self.codetest(code, 'f38', [117]) == [234]*15
 
     def test_star_arg(self):
         code = ''' 
diff --git a/pypy/interpreter/test/test_nestedscope.py b/pypy/interpreter/test/test_nestedscope.py
--- a/pypy/interpreter/test/test_nestedscope.py
+++ b/pypy/interpreter/test/test_nestedscope.py
@@ -57,7 +57,7 @@
         assert keys == ['h', 'x']
 
     def test_lambda_in_genexpr(self):
-        assert eval('map(apply, (lambda: t for t in range(10)))') == list(range(10))
+        assert [x() for x in (lambda: x for x in range(10))] == list(range(10))
 
     def test_cell_contents(self):
         def f(x):
diff --git a/pypy/module/_hashlib/test/test_hashlib.py b/pypy/module/_hashlib/test/test_hashlib.py
--- a/pypy/module/_hashlib/test/test_hashlib.py
+++ b/pypy/module/_hashlib/test/test_hashlib.py
@@ -72,16 +72,15 @@
                           "4effe5d7a31879b8b7a10fd2f544c4ca268ecc6793923583"),
             }
         import _hashlib
-        test_string = "Nobody inspects the spammish repetition"
+        test_string = b"Nobody inspects the spammish repetition"
         for hash_name, expected in sorted(expected_results.items()):
             try:
                 m = _hashlib.new(hash_name)
-            except ValueError, e:
-                print 'skipped %s: %s' % (hash_name, e)
+            except ValueError as e:
+                print('skipped %s: %s' % (hash_name, e))
                 continue
             m.update(test_string)
             got = m.hexdigest()
             assert got and type(got) is str and len(got) % 2 == 0
-            got.decode('hex')
             if expected is not None:
                 assert got == expected
diff --git a/pypy/module/itertools/test/test_itertools.py b/pypy/module/itertools/test/test_itertools.py
--- a/pypy/module/itertools/test/test_itertools.py
+++ b/pypy/module/itertools/test/test_itertools.py
@@ -223,9 +223,9 @@
         assert list(itertools.islice(range(100), 10, 3)) == []
 
         # new in 2.5: start=None or step=None
-        assert list(itertools.islice(range(10), None)) == range(10)
-        assert list(itertools.islice(range(10), None,None)) == range(10)
-        assert list(itertools.islice(range(10), None,None,None)) == range(10)
+        assert list(itertools.islice(range(10), None)) == list(range(10))
+        assert list(itertools.islice(range(10), None,None)) == list(range(10))
+        assert list(itertools.islice(range(10), None,None,None)) == list(range(10))
 
     def test_islice_dropitems_exact(self):
         import itertools
@@ -758,7 +758,7 @@
                 self.e = e
             def __iter__(self): # its iterator is itself
                 return self
-            def next(self):
+            def __next__(self):
                 if self.t > 0:
                     self.t -= 1
                     return self.o
@@ -949,7 +949,7 @@
                 self.e = e
             def __iter__(self): # its iterator is itself
                 return self
-            def next(self):
+            def __next__(self):
                 if self.t > 0:
                     self.t -= 1
                     return self.o
diff --git a/pypy/module/mmap/test/test_mmap.py b/pypy/module/mmap/test/test_mmap.py
--- a/pypy/module/mmap/test/test_mmap.py
+++ b/pypy/module/mmap/test/test_mmap.py
@@ -528,16 +528,6 @@
 
         f.close()
 
-    def test_sequence_type(self):
-        from mmap import mmap
-        f = open(self.tmpname + "x", "wb+")
-        f.write(b"foobar")
-        f.flush()
-        m = mmap(f.fileno(), 6)
-        import operator
-        assert operator.isSequenceType(m)
-        assert not operator.isMappingType(m)
-
     def test_buffer(self):
         from mmap import mmap
         f = open(self.tmpname + "y", "bw+")
diff --git a/pypy/objspace/std/test/test_typeobject.py b/pypy/objspace/std/test/test_typeobject.py
--- a/pypy/objspace/std/test/test_typeobject.py
+++ b/pypy/objspace/std/test/test_typeobject.py
@@ -116,9 +116,8 @@
     def test_call_type(self):
         assert type(42) is int
         C = type('C', (object,), {'x': lambda: 42})
-        unbound_meth = C.x
-        raises(TypeError, unbound_meth)
-        assert unbound_meth.__func__() == 42
+        func = C.x
+        assert func() == 42
         raises(TypeError, type)
         raises(TypeError, type, 'test', (object,))
         raises(TypeError, type, 'test', (object,), {}, 42)
@@ -127,6 +126,7 @@
         raises(TypeError, type, 'test', (object,), 42)
 
     def test_call_type_subclass(self):
+        """
         class A(type):
             pass
 
@@ -137,18 +137,20 @@
             counter = 0
             def __init__(self, *args):
                 T.counter += 1
-        class C:
-            __metaclass__ = T
+        class C(metaclass=T):
+            pass
         assert T.counter == 1
         a = C()
         assert T.counter == 1
         assert type(a) is C
         assert T.counter == 1
+        """
 
     def test_bases(self):
+        """
         assert int.__bases__ == (object,)
-        class X:
-            __metaclass__ = type
+        class X(metaclass=type):
+            pass
         assert X.__bases__ ==  (object,)
         class Y(X): pass
         assert Y.__bases__ ==  (X,)
@@ -158,6 +160,7 @@
         Z.__bases__ = (X,)
         #print Z.__bases__
         assert Z.__bases__ == (X,)
+        """
 
     def test_mutable_bases(self):
         # from CPython's test_descr
@@ -248,30 +251,8 @@
         else:
             assert 0, "shouldn't be able to create inheritance cycles"
 
-        # let's throw a classic class into the mix:
-        class Classic:
-            def meth2(self):
-                return 3
-
-        D.__bases__ = (C, Classic)
-
-        assert d.meth2() == 3
-        assert e.meth2() == 3
-        try:
-            d.a
-        except AttributeError:
-            pass
-        else:
-            assert 0, "attribute should have vanished"
-
-        try:
-            D.__bases__ = (Classic,)
-        except TypeError:
-            pass
-        else:
-            assert 0, "new-style class must have a new-style base"
-
     def test_mutable_bases_with_failing_mro(self):
+        """
         class WorkOnce(type):
             def __new__(self, name, bases, ns):
                 self.flag = 0
@@ -303,11 +284,11 @@
         class E(D):
             pass
 
-        class F(D):
-            __metaclass__ = WorkOnce
+        class F(D, metaclass=WorkOnce):
+            pass
 
-        class G(D):
-            __metaclass__ = WorkAlways
+        class G(D, metaclass=WorkAlways):
+            pass
 
         # Immediate subclasses have their mro's adjusted in alphabetical
         # order, so E's will get adjusted before adjusting F's fails.  We
@@ -323,6 +304,7 @@
             assert E.__mro__ == E_mro_before
         else:
             assert 0, "exception not propagated"
+            """
 
     def test_mutable_bases_catch_mro_conflict(self):
         class A(object):
@@ -482,31 +464,15 @@
             raise AssertionError("this multiple inheritance should fail")
 
     def test_outer_metaclass(self):
+        """
         class OuterMetaClass(type):
             pass
 
-        class HasOuterMetaclass(object):
-            __metaclass__ = OuterMetaClass
+        class HasOuterMetaclass(metaclass=OuterMetaClass):
+            pass
 
         assert type(HasOuterMetaclass) == OuterMetaClass
-        assert type(HasOuterMetaclass) == HasOuterMetaclass.__metaclass__
-
-    def test_inner_metaclass(self):
-        class HasInnerMetaclass(object):
-            class __metaclass__(type):
-                pass
-
-        assert type(HasInnerMetaclass) == HasInnerMetaclass.__metaclass__
-
-    def test_implicit_metaclass(self):
-        class __metaclass__(type):
-            pass
-
-        g = {'__metaclass__': __metaclass__}
-        exec("class HasImplicitMetaclass: pass\n", g)
-
-        HasImplicitMetaclass = g['HasImplicitMetaclass']
-        assert type(HasImplicitMetaclass) == __metaclass__
+        """
 
     def test_mro(self):
         class A_mro(object):
@@ -529,6 +495,7 @@
         assert type.mro(B_mro) == [B_mro, A_mro, object]
 
     def test_abstract_mro(self):
+        """
         class A1:    # old-style class
             pass
         class B1(A1):
@@ -537,10 +504,11 @@
             pass
         class D1(B1, C1):
             pass
-        class E1(D1, object):
-            __metaclass__ = type
+        class E1(D1, object, metaclass=type):
+            pass
         # old-style MRO in the classical part of the parent hierarchy
         assert E1.__mro__ == (E1, D1, B1, A1, C1, object)
+        """
 
     def test_nodoc(self):
         class NoDoc(object):
@@ -581,21 +549,23 @@
         assert ImmutableDoc.__doc__ == 'foo'
 
     def test_metaclass_conflict(self):
-
+        """
         class T1(type):
             pass
         class T2(type):
             pass
-        class D1:
-            __metaclass__ = T1
-        class D2:
-            __metaclass__ = T2
+        class D1(metaclass=T1):
+            pass
+        class D2(metaclass=T2):
+            pass
         def conflict():
             class C(D1,D2):
                 pass
         raises(TypeError, conflict)
+        """
 
     def test_metaclass_choice(self):
+        """
         events = []
         
         class T1(type):
@@ -603,8 +573,8 @@
                 events.append(args)
                 return type.__new__(*args)
 
-        class D1:
-            __metaclass__ = T1
+        class D1(metaclass=T1):
+            pass
 
         class C(D1):
             pass
@@ -619,6 +589,7 @@
         assert type(D1) is T1
         assert type(C) is T1
         assert type(G) is T1
+        """
     
     def test_descr_typecheck(self):
         raises(TypeError,type.__dict__['__name__'].__get__,1)
@@ -753,6 +724,7 @@
         raises(TypeError, "class D(A, C): pass")
 
     def test_data_descriptor_without_get(self):
+        """
         class Descr(object):
             def __init__(self, name):
                 self.name = name
@@ -760,22 +732,24 @@
                 pass
         class Meta(type):
             pass
-        class X(object):
-            __metaclass__ = Meta
+        class X(object, metaclass=Meta):
+            pass
         X.a = 42
         Meta.a = Descr("a")
         assert X.a == 42
+        """
 
     def test_user_defined_mro_cls_access(self):
+        """
         d = []
         class T(type):
             def mro(cls):
                 d.append(cls.__dict__)
                 return type.mro(cls)
-        class C:
-            __metaclass__ = T
+        class C(metaclass=T):
+            pass
         assert d
-        assert sorted(d[0].keys()) == ['__dict__','__doc__','__metaclass__','__module__', '__weakref__']
+        assert sorted(d[0].keys()) == ['__dict__', '__doc__', '__module__', '__weakref__']
         d = []
         class T(type):
             def mro(cls):
@@ -784,18 +758,13 @@
                 except AttributeError:
                     d.append('miss')
                 return type.mro(cls)
-        class C:
+        class C(metaclass=T):
             def x(cls):
                 return 1
             x = classmethod(x)
-            __metaclass__ = T
         assert d == ['miss']
         assert C.x() == 1
-
-    def test_only_classic_bases_fails(self):
-        class C:
-            pass
-        raises(TypeError, type, 'D', (C,), {})
+        """
 
     def test_set___class__(self):
         raises(TypeError, "1 .__class__ = int")
@@ -1098,6 +1067,7 @@
                         **{"objspace.std.getattributeshortcut": True})
 
     def test_reset_logic(self):
+        """
         class X(object):
             pass
 
@@ -1118,8 +1088,8 @@
         class M(type):
             pass
 
-        class X(object):
-            __metaclass__ = M
+        class X(metaclass=M):
+            pass
 
         class Y(X):
             pass
@@ -1134,6 +1104,7 @@
         X.__getattribute__ = ga2
 
         assert y.x == 'GA2'
+        """
 
 class TestNewShortcut:
 


More information about the pypy-commit mailing list