Philip Jenvey avatar Philip Jenvey committed e9c4247

2to3

Comments (0)

Files changed (1)

pypy/objspace/std/test/test_typeobject.py

         C = type('C', (object,), {'x': lambda: 42})
         unbound_meth = C.x
         raises(TypeError, unbound_meth)
-        assert unbound_meth.im_func() == 42
+        assert unbound_meth.__func__() == 42
         raises(TypeError, type)
         raises(TypeError, type, 'test', (object,))
         raises(TypeError, type, 'test', (object,), {}, 42)
 
         try:
             D.__bases__ = ()
-        except TypeError, msg:
+        except TypeError as msg:
             if str(msg) == "a new-style class can't have only classic bases":
                 assert 0, "wrong error message for .__bases__ = ()"
         else:
                 return super(WorkOnce, self).__new__(WorkOnce, name, bases, ns)
             def mro(instance):
                 if instance.flag > 0:
-                    raise RuntimeError, "bozo"
+                    raise RuntimeError("bozo")
                 else:
                     instance.flag += 1
                     return type.mro(instance)
         except TypeError:
             pass
         else:
-            raise TestFailed, "didn't catch MRO conflict"
+            raise TestFailed("didn't catch MRO conflict")
 
     def test_mutable_bases_versus_nonheap_types(self):
         class A(int):
         except TypeError:
             pass
         else:
-            raise AssertionError, "this multiple inheritance should fail"
+            raise AssertionError("this multiple inheritance should fail")
 
     def test_outer_metaclass(self):
         class OuterMetaClass(type):
             pass
 
         g = {'__metaclass__': __metaclass__}
-        exec "class HasImplicitMetaclass: pass\n" in g
+        exec("class HasImplicitMetaclass: pass\n", g)
 
         HasImplicitMetaclass = g['HasImplicitMetaclass']
         assert type(HasImplicitMetaclass) == __metaclass__
         try:
             assert NoDoc.__doc__ == None
         except AttributeError:
-            raise AssertionError, "__doc__ missing!"
+            raise AssertionError("__doc__ missing!")
 
     def test_explicitdoc(self):
         class ExplicitDoc(object):
             #       we always raise AttributeError.
             pass
         else:
-            raise AssertionError, '__doc__ should not be writable'
+            raise AssertionError('__doc__ should not be writable')
 
         assert ImmutableDoc.__doc__ == 'foo'
 
             __slots__ = "abc"
 
         class B(object):
-            __slots__ = u"abc"
+            __slots__ = "abc"
 
         a = A()
         a.abc = "awesome"
 
     def test_module(self):
         def f(): pass
-        assert object.__module__ == '__builtin__'
-        assert int.__module__ == '__builtin__'
-        assert type.__module__ == '__builtin__'
-        assert type(f).__module__ == '__builtin__'
+        assert object.__module__ == 'builtins'
+        assert int.__module__ == 'builtins'
+        assert type.__module__ == 'builtins'
+        assert type(f).__module__ == 'builtins'
         d = {'__name__': 'yay'}
-        exec """class A(object):\n  pass\n""" in d
+        exec("""class A(object):\n  pass\n""", d)
         A = d['A']
         assert A.__module__ == 'yay'
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.