Manuel Jacob avatar Manuel Jacob committed 976cb01

Fix these tests to use the new API for _rawffi char Arrays.

Comments (0)

Files changed (1)

pypy/module/_rawffi/test/test_nested.py

         assert S.fieldoffset('x') == 0
         assert S.fieldoffset('s1') == S1.alignment
         s = S()
-        s.x = ord('G')
+        s.x = b'G'
         raises(TypeError, 's.s1')
         assert s.fieldaddress('s1') == s.buffer + S.fieldoffset('s1')
         s1 = S1.fromaddress(s.fieldaddress('s1'))
-        s1.c = ord('H')
+        s1.c = b'H'
         rawbuf = _rawffi.Array('c').fromaddress(s.buffer, S.size)
-        assert rawbuf[0] == ord('G')
-        assert rawbuf[S1.alignment + S1.fieldoffset('c')] == ord('H')
+        assert rawbuf[0] == b'G'
+        assert rawbuf[S1.alignment + S1.fieldoffset('c')] == b'H'
         s.free()
 
     def test_array_of_structures(self):
         a = A(3)
         raises(TypeError, "a[0]")
         s0 = S.fromaddress(a.buffer)
-        s0.c = ord('B')
+        s0.c = b'B'
         assert a.itemaddress(1) == a.buffer + S.size
         s1 = S.fromaddress(a.itemaddress(1))
-        s1.c = ord('A')
+        s1.c = b'A'
         s2 = S.fromaddress(a.itemaddress(2))
-        s2.c = ord('Z')
+        s2.c = b'Z'
         rawbuf = _rawffi.Array('c').fromaddress(a.buffer, S.size * len(a))
         ofs = S.fieldoffset('c')
-        assert rawbuf[0*S.size+ofs] == ord('B')
-        assert rawbuf[1*S.size+ofs] == ord('A')
-        assert rawbuf[2*S.size+ofs] == ord('Z')
+        assert rawbuf[0*S.size+ofs] == b'B'
+        assert rawbuf[1*S.size+ofs] == b'A'
+        assert rawbuf[2*S.size+ofs] == b'Z'
         a.free()
 
     def test_array_of_array(self):
         assert S.fieldoffset('x') == 0
         assert S.fieldoffset('ar') == A5alignment
         s = S()
-        s.x = ord('G')
+        s.x = b'G'
         raises(TypeError, 's.ar')
         assert s.fieldaddress('ar') == s.buffer + S.fieldoffset('ar')
         a1 = A.fromaddress(s.fieldaddress('ar'), 5)
         a1[4] = 33
         rawbuf = _rawffi.Array('c').fromaddress(s.buffer, S.size)
-        assert rawbuf[0] == ord('G')
+        assert rawbuf[0] == b'G'
         sizeofint = struct.calcsize("i")
         v = 0
         for i in range(sizeofint):
-            v += rawbuf[A5alignment + sizeofint*4+i]
+            v += ord(rawbuf[A5alignment + sizeofint*4+i])
         assert v == 33
         s.free()
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.