Ejemplo n.º 1
0
            """))


class PyFileTest(FunctionalTestCase):
    
    def testPyFile(self):
        # this is the CPython file type, interpreted just like an extension type
        mapper = PythonMapper(DLL_PATH)
        try:
            f1 = mapper.CPyFileClass(os.path.join(self.testDir, 'newFile'), 'w')
            f1.write("hello!")
            f1.close()
            
            f2 = mapper.CPyFileClass(os.path.join(self.testDir, 'newFile'), 'r')
            assert f2.read() == 'hello!'
            f2.close()
        finally:
            mapper.Dispose()


Sqlite3Test = TrivialModuleTestCase('sqlite3') # test PATH manipulation in LoadModule
PySVNTest = TrivialModuleTestCase('pysvn') # test misleading names passed to Py_InitModule4
MMapTest = TrivialModuleTestCase('mmap')
CsvTest = TrivialModuleTestCase('csv')

suite = automakesuite(locals())
if __name__ == '__main__':
    run(suite)


Ejemplo n.º 2
0
        testBytes = self.byteArrayFromString(testString)
        testData = self.ptrFromByteArray(testBytes)
        testLength = len(testString)

        try:
            strPtr = mapper.Store(testString)
            baseSize = Marshal.SizeOf(PyStringObject)

            self.assertEquals(allocs, [(strPtr, testLength + baseSize)],
                              "allocated wrong")
            self.assertHasStringType(strPtr, mapper)
            self.assertStringObjectHasLength(strPtr, testLength)
            self.assertStringObjectHasDataBytes(strPtr, testBytes)
            self.assertEquals(mapper.Retrieve(strPtr), testString,
                              "failed to read string data")

            strPtr2 = mapper.Store(testString)
            self.assertEquals(strPtr2, strPtr,
                              "did not remember already had this string")
            self.assertEquals(mapper.RefCount(strPtr), 2,
                              "did not incref on store")
        finally:
            mapper.Dispose()
            deallocTypes()


suite = automakesuite(locals())

if __name__ == '__main__':
    run(suite)