예제 #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 ')
예제 #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 ')
예제 #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 ')
예제 #4
0
파일: test_nsdata.py 프로젝트: aosm/pyobjc
    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 ')
예제 #5
0
 def testBytesRaises(self):
     b = PyObjC_TestClass3.makeDataWithBytes_method_(MyData5, 1)
     self.assertRaises(ValueError, b.bytes)
예제 #6
0
 def testBytesNone(self):
     b = PyObjC_TestClass3.makeDataWithBytes_method_(MyData4, 1)
     self.assertEquals(b.bytes(), None)
예제 #7
0
 def testInit(self):
     r = PyObjC_TestClass3.makeDataWithBytes_method_(MyData2, 1)
     self.assertEquals(r, ('init', 'hello world', 11))
예제 #8
0
 def testData(self):
     r = PyObjC_TestClass3.makeDataWithBytes_method_(MyData, 0)
     self.assertEquals(r, ('data', 'hello world', 11))
예제 #9
0
 def testInit(self):
     r = PyObjC_TestClass3.makeDataWithBytes_method_(MyData2, 1)
     self.assertEqual(r, ("init", b"hello world", 11))
예제 #10
0
 def testData(self):
     r = PyObjC_TestClass3.makeDataWithBytes_method_(MyData, 0)
     self.assertEqual(r, ("data", b"hello world", 11))
예제 #11
0
파일: test_nsdata.py 프로젝트: aosm/pyobjc
 def testBytesRaises(self):
     b = PyObjC_TestClass3.makeDataWithBytes_method_(MyData5, 1)
     self.assertRaises(ValueError, b.bytes)
예제 #12
0
파일: test_nsdata.py 프로젝트: aosm/pyobjc
 def testBytesNone(self):
     b = PyObjC_TestClass3.makeDataWithBytes_method_(MyData4, 1)
     self.assertEqual(b.bytes(), None)
예제 #13
0
파일: test_nsdata.py 프로젝트: aosm/pyobjc
 def testInit(self):
     r = PyObjC_TestClass3.makeDataWithBytes_method_(MyData2, 1)
     self.assertEqual(r, ('init', b'hello world', 11))
예제 #14
0
파일: test_nsdata.py 프로젝트: aosm/pyobjc
 def testData(self):
     r = PyObjC_TestClass3.makeDataWithBytes_method_(MyData, 0)
     self.assertEqual(r, ('data', b'hello world', 11))