Fix qglbuffer test on Python3.
This commit is contained in:
parent
1cefc09118
commit
7202e2b8df
2 changed files with 11 additions and 7 deletions
|
|
@ -5,7 +5,7 @@ import unittest
|
||||||
|
|
||||||
from PySide.QtCore import QByteArray
|
from PySide.QtCore import QByteArray
|
||||||
from PySide.QtOpenGL import QGLBuffer, QGLWidget
|
from PySide.QtOpenGL import QGLBuffer, QGLWidget
|
||||||
|
import py3kcompat as py3k
|
||||||
from helper import UsesQApplication
|
from helper import UsesQApplication
|
||||||
|
|
||||||
class QGLBufferTest(UsesQApplication):
|
class QGLBufferTest(UsesQApplication):
|
||||||
|
|
@ -16,9 +16,9 @@ class QGLBufferTest(UsesQApplication):
|
||||||
b = QGLBuffer()
|
b = QGLBuffer()
|
||||||
b.setUsagePattern(QGLBuffer.DynamicDraw)
|
b.setUsagePattern(QGLBuffer.DynamicDraw)
|
||||||
|
|
||||||
self.assert_(b.create())
|
self.assertTrue(b.create())
|
||||||
self.assert_(b.bufferId() != 0)
|
self.assertTrue(b.bufferId() != 0)
|
||||||
self.assert_(b.bind())
|
self.assertTrue(b.bind())
|
||||||
|
|
||||||
data = QByteArray("12345")
|
data = QByteArray("12345")
|
||||||
b.allocate(data)
|
b.allocate(data)
|
||||||
|
|
@ -26,15 +26,15 @@ class QGLBufferTest(UsesQApplication):
|
||||||
|
|
||||||
m = b.map(QGLBuffer.ReadOnly)
|
m = b.map(QGLBuffer.ReadOnly)
|
||||||
if m:
|
if m:
|
||||||
self.assertEqual(m, buffer(data.data()))
|
self.assertEqual(m, py3k.buffer(py3k.b(data.data())))
|
||||||
b.unmap()
|
b.unmap()
|
||||||
|
|
||||||
m = b.map(QGLBuffer.ReadWrite)
|
m = b.map(QGLBuffer.ReadWrite)
|
||||||
m[3] = 'A'
|
m[3] = py3k.b('A')
|
||||||
b.unmap()
|
b.unmap()
|
||||||
result, rdata = b.read(3, 1)
|
result, rdata = b.read(3, 1)
|
||||||
self.assertTrue(result)
|
self.assertTrue(result)
|
||||||
self.assertEqual('A', rdata.data())
|
self.assertEqual(py3k.b('A'), rdata.data())
|
||||||
else:
|
else:
|
||||||
print(" memory mapping is not possible in this OpenGL implementation.")
|
print(" memory mapping is not possible in this OpenGL implementation.")
|
||||||
b.release()
|
b.release()
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
def b(s):
|
def b(s):
|
||||||
|
if type(s) == bytes:
|
||||||
|
return s
|
||||||
return bytes(s, "UTF8")
|
return bytes(s, "UTF8")
|
||||||
|
|
||||||
def buffer_(s):
|
def buffer_(s):
|
||||||
|
|
@ -6,6 +8,8 @@ def buffer_(s):
|
||||||
return None
|
return None
|
||||||
elif type(s) == str:
|
elif type(s) == str:
|
||||||
return bytes(s, "UTF8")
|
return bytes(s, "UTF8")
|
||||||
|
elif type(s) == bytes:
|
||||||
|
return s
|
||||||
else:
|
else:
|
||||||
memoryview(s)
|
memoryview(s)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue