Exemplo n.º 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 ')
Exemplo n.º 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 ')
Exemplo n.º 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 ')
Exemplo n.º 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 ')
Exemplo n.º 5
0
 def testBytesRaises(self):
     b = PyObjC_TestClass3.makeDataWithBytes_method_(MyData5, 1)
     self.assertRaises(ValueError, b.bytes)
Exemplo n.º 6
0
 def testBytesNone(self):
     b = PyObjC_TestClass3.makeDataWithBytes_method_(MyData4, 1)
     self.assertEquals(b.bytes(), None)
Exemplo n.º 7
0
 def testInit(self):
     r = PyObjC_TestClass3.makeDataWithBytes_method_(MyData2, 1)
     self.assertEquals(r, ('init', 'hello world', 11))
Exemplo n.º 8
0
 def testData(self):
     r = PyObjC_TestClass3.makeDataWithBytes_method_(MyData, 0)
     self.assertEquals(r, ('data', 'hello world', 11))
Exemplo n.º 9
0
 def testInit(self):
     r = PyObjC_TestClass3.makeDataWithBytes_method_(MyData2, 1)
     self.assertEqual(r, ("init", b"hello world", 11))
Exemplo n.º 10
0
 def testData(self):
     r = PyObjC_TestClass3.makeDataWithBytes_method_(MyData, 0)
     self.assertEqual(r, ("data", b"hello world", 11))
Exemplo n.º 11
0
 def testBytesRaises(self):
     b = PyObjC_TestClass3.makeDataWithBytes_method_(MyData5, 1)
     self.assertRaises(ValueError, b.bytes)
Exemplo n.º 12
0
 def testBytesNone(self):
     b = PyObjC_TestClass3.makeDataWithBytes_method_(MyData4, 1)
     self.assertEqual(b.bytes(), None)
Exemplo n.º 13
0
 def testInit(self):
     r = PyObjC_TestClass3.makeDataWithBytes_method_(MyData2, 1)
     self.assertEqual(r, ('init', b'hello world', 11))
Exemplo n.º 14
0
 def testData(self):
     r = PyObjC_TestClass3.makeDataWithBytes_method_(MyData, 0)
     self.assertEqual(r, ('data', b'hello world', 11))