本文整理汇总了Python中PyObjCTest.testhelper.PyObjC_TestClass3.makeDataWithBytes_method_方法的典型用法代码示例。如果您正苦于以下问题:Python PyObjC_TestClass3.makeDataWithBytes_method_方法的具体用法?Python PyObjC_TestClass3.makeDataWithBytes_method_怎么用?Python PyObjC_TestClass3.makeDataWithBytes_method_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyObjCTest.testhelper.PyObjC_TestClass3
的用法示例。
在下文中一共展示了PyObjC_TestClass3.makeDataWithBytes_method_方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testBytes
# 需要导入模块: from PyObjCTest.testhelper import PyObjC_TestClass3 [as 别名]
# 或者: from PyObjCTest.testhelper.PyObjC_TestClass3 import makeDataWithBytes_method_ [as 别名]
def testBytes(self):
r = PyObjC_TestClass3.makeDataWithBytes_method_(MyData3, 1)
b = PyObjC_TestClass3.getBytes_(r)
self.assertEquals(str(b.bytes()), 'hello world')
self.assertEquals(b.getBytes_length_(None, 4), 'hell')
self.assertEquals(b.getBytes_range_(None, NSRange(2, 4)), 'llo ')
示例2: testBytes
# 需要导入模块: from PyObjCTest.testhelper import PyObjC_TestClass3 [as 别名]
# 或者: from PyObjCTest.testhelper.PyObjC_TestClass3 import makeDataWithBytes_method_ [as 别名]
def testBytes(self):
r = PyObjC_TestClass3.makeDataWithBytes_method_(MyData3, 1)
b = PyObjC_TestClass3.getBytes_(r)
# Check for memoryview
if isinstance(b.bytes(), memoryview):
self.assertEqual(b.bytes().tobytes(), b'hello world')
else:
self.assertEqual(bytes(b.bytes()), b'hello world')
self.assertEqual(b.getBytes_length_(None, 4), b'hell')
self.assertEqual(b.getBytes_range_(None, NSRange(2, 4)), b'llo ')
示例3: testBytesRaises
# 需要导入模块: from PyObjCTest.testhelper import PyObjC_TestClass3 [as 别名]
# 或者: from PyObjCTest.testhelper.PyObjC_TestClass3 import makeDataWithBytes_method_ [as 别名]
def testBytesRaises(self):
b = PyObjC_TestClass3.makeDataWithBytes_method_(MyData5, 1)
self.assertRaises(ValueError, b.bytes)
示例4: testBytesNone
# 需要导入模块: from PyObjCTest.testhelper import PyObjC_TestClass3 [as 别名]
# 或者: from PyObjCTest.testhelper.PyObjC_TestClass3 import makeDataWithBytes_method_ [as 别名]
def testBytesNone(self):
b = PyObjC_TestClass3.makeDataWithBytes_method_(MyData4, 1)
self.assertEqual(b.bytes(), None)
示例5: testInit
# 需要导入模块: from PyObjCTest.testhelper import PyObjC_TestClass3 [as 别名]
# 或者: from PyObjCTest.testhelper.PyObjC_TestClass3 import makeDataWithBytes_method_ [as 别名]
def testInit(self):
r = PyObjC_TestClass3.makeDataWithBytes_method_(MyData2, 1)
self.assertEqual(r, ('init', b'hello world', 11))
示例6: testData
# 需要导入模块: from PyObjCTest.testhelper import PyObjC_TestClass3 [as 别名]
# 或者: from PyObjCTest.testhelper.PyObjC_TestClass3 import makeDataWithBytes_method_ [as 别名]
def testData(self):
r = PyObjC_TestClass3.makeDataWithBytes_method_(MyData, 0)
self.assertEqual(r, ('data', b'hello world', 11))