Commits

Philip Jenvey committed bce5675

adapt to py3

Comments (0)

Files changed (2)

pypy/module/test_lib_pypy/test_resource.py

             if i < 2:
                 expected_type = float
             else:
-                expected_type = (int, long)
+                expected_type = int
             assert isinstance(x[i], expected_type)

pypy/module/test_lib_pypy/test_structseq.py

 
     def w_get_mydata(self):
         _structseq = self._structseq
-        ssfield = _structseq.structseqfield
-        class mydata:
-            __metaclass__ = _structseq.structseqtype
-
-            st_mode  = ssfield(0, "protection bits")
-            st_ino   = ssfield(1)
-            st_dev   = ssfield(2)
-            st_nlink = ssfield(3)
-            st_uid   = ssfield(4)
-            st_gid   = ssfield(5)
-            st_size  = ssfield(6)
-            _st_atime_as_int = ssfield(7)
-            _st_mtime_as_int = ssfield(8)
-            _st_ctime_as_int = ssfield(9)
-            # skip to higher numbers for fields not part of the sequence.
-            # the numbers are only used to ordering
-            st_rdev  = ssfield(50, "device type (if inode device)")
-            st_atime = ssfield(57,
-                               default=lambda self: self._st_atime_as_int)
-            st_mtime = ssfield(58,
-                               default=lambda self: self._st_mtime_as_int)
-            st_ctime = ssfield(59,
-                               default=lambda self: self._st_ctime_as_int)
-        return mydata
+        ns = dict(_structseq=_structseq,
+                  ssfield=_structseq.structseqfield)
+        # need to exec since it uses the py3k-only metaclass syntax
+        exec("""\
+class mydata(metaclass=_structseq.structseqtype):
+    st_mode  = ssfield(0, "protection bits")
+    st_ino   = ssfield(1)
+    st_dev   = ssfield(2)
+    st_nlink = ssfield(3)
+    st_uid   = ssfield(4)
+    st_gid   = ssfield(5)
+    st_size  = ssfield(6)
+    _st_atime_as_int = ssfield(7)
+    _st_mtime_as_int = ssfield(8)
+    _st_ctime_as_int = ssfield(9)
+    # skip to higher numbers for fields not part of the sequence.
+    # the numbers are only used to ordering
+    st_rdev  = ssfield(50, "device type (if inode device)")
+    st_atime = ssfield(57,
+                       default=lambda self: self._st_atime_as_int)
+    st_mtime = ssfield(58,
+                       default=lambda self: self._st_mtime_as_int)
+    st_ctime = ssfield(59,
+                       default=lambda self: self._st_ctime_as_int)
+""", ns)
+        return ns['mydata']
 
     def test_class(self):
         mydata = self.get_mydata()
         assert x.st_ctime == 109    # copied by the default=lambda...
         assert x.st_rdev  == 110
         assert len(x)     == 10
-        assert list(x)    == range(100, 110)
+        assert list(x)    == list(range(100, 110))
         assert x + (5,)   == tuple(range(100, 110)) + (5,)
         assert x[4:12:2]  == (104, 106, 108)
         assert 104 in x
     def test_compare_like_tuple(self):
         mydata = self.get_mydata()
         x = mydata(range(100, 111))
-        y = mydata(range(100, 110) + [555])
+        y = mydata(list(range(100, 110)) + [555])
         assert x == tuple(range(100, 110))
         assert x == y    # blame CPython
         assert hash(x) == hash(y) == hash(tuple(range(100, 110)))
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.