mixer_test.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:Projects 作者: it2school 项目源码 文件源码
def test_get_raw(self):
        from ctypes import pythonapi, c_void_p, py_object

        try:
            Bytes_FromString = pythonapi.PyBytes_FromString
        except:
            Bytes_FromString = pythonapi.PyString_FromString
        Bytes_FromString.restype = c_void_p
        Bytes_FromString.argtypes = [py_object]
        mixer.init()
        try:
            samples = as_bytes('abcdefgh') # keep byte size a multiple of 4
            snd = mixer.Sound(buffer=samples)
            raw = snd.get_raw()
            self.assertTrue(isinstance(raw, bytes_))
            self.assertNotEqual(snd._samples_address, Bytes_FromString(samples))
            self.assertEqual(raw, samples)
        finally:
            mixer.quit()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号