Example #1
0
    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 ')
Example #2
0
    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 ')
Example #3
0
    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 ')
Example #4
0
    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 ')