当前位置: 首页>>代码示例>>Python>>正文


Python runtest.makesuite函数代码示例

本文整理汇总了Python中tests.utils.runtest.makesuite函数的典型用法代码示例。如果您正苦于以下问题:Python makesuite函数的具体用法?Python makesuite怎么用?Python makesuite使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了makesuite函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testPySequence_Tuple_withTuple

                    result = -1
                self.assertEquals(mapper.PySequence_Contains(mapper.Store(seq), mapper.Store(val)), result)
                self.assertMapperHasError(mapper, error)

    @WithMapper
    def testPySequence_Tuple_withTuple(self, mapper, _):
        tuplePtr = mapper.Store((1, 2, 3))
        self.assertEquals(mapper.PySequence_Tuple(tuplePtr), tuplePtr)
        self.assertEquals(mapper.RefCount(tuplePtr), 2)
        
    
    @WithMapper
    def testPySequence_Tuple_notTuple(self, mapper, _):
        listPtr = mapper.Store([4, 5, 6])
        tuplePtr = mapper.PySequence_Tuple(listPtr)
        self.assertEquals(mapper.Retrieve(tuplePtr), (4, 5, 6))
    
    
    @WithMapper
    def testPySequence_Tuple_notSequence(self, mapper, _):
        self.assertEquals(mapper.PySequence_Tuple(mapper.Store(123)), IntPtr.Zero)
        self.assertMapperHasError(mapper, TypeError)


suite = makesuite(
    SequenceFunctionsTest,
)

if __name__ == '__main__':
    run(suite)
开发者ID:netcharm,项目名称:ironclad,代码行数:30,代码来源:sequencetest.py

示例2: C

        path = os.path.join(testDir, "test")

        class C(object):
            __str__ = lambda s: "str"
            __repr__ = lambda s: "repr"

        f = open(path, "w")
        try:
            fPtr = mapper.Store(f)
            cPtr = mapper.Store(C())
            self.assertEquals(mapper.IC_PyFile_WriteObject(cPtr, fPtr, 0), 0)
            self.assertEquals(mapper.IC_PyFile_WriteObject(cPtr, fPtr, 1), 0)
            mapper.DecRef(fPtr)
            self.assertEquals(mapper.IC_PyFile_WriteObject(cPtr, mapper.Store(object()), 0), -1)
            self.assertMapperHasError(mapper, TypeError)
        finally:
            f.close()

        f = open(path)
        try:
            result = f.read()
            self.assertEquals(result, "reprstr")
        finally:
            f.close()


suite = makesuite(PyFile_Type_Test, PyFileAPIFunctions)

if __name__ == "__main__":
    run(suite)
开发者ID:netcharm,项目名称:ironclad,代码行数:30,代码来源:filetest.py

示例3: testRealloc

        self.assertRaises(KeyError, allocator.Free, ptr3)
        
        
    def testRealloc(self):
        def DoTest(size):
            allocator = HGlobalAllocator()
            ptr1 = allocator.Alloc(REASONABLE_SIZE)
            ptr2 = allocator.Realloc(ptr1, REASONABLE_SIZE * (2 ** size))
            if (ptr1 == ptr2):
                return False
            
            self.assertEquals(allocator.Contains(ptr1), False)
            self.assertEquals(allocator.Contains(ptr2), True)
            self.assertRaises(KeyError, allocator.Free, ptr1)
            allocator.FreeAll()
            self.assertEquals(allocator.Contains(ptr2), False)
            self.assertRaises(KeyError, allocator.Free, ptr2)
            return True
        
        i = 1
        while not DoTest(i):
            i = i + 1
            if i > 5:
                self.fail("failed to convince allocator to reallocate into a new block")
        
    

suite = makesuite(HGlobalAllocatorTest)

if __name__ == '__main__':
    run(suite)
开发者ID:IronLanguages,项目名称:ironclad,代码行数:31,代码来源:hglobalallocatortest.py

示例4: testPyTuple_GetSlice

    @WithMapper
    def testPyTuple_GetSlice(self, mapper, _):
        def TestSlice(originalTuplePtr, start, stop):
            newTuplePtr = mapper.PyTuple_GetSlice(originalTuplePtr, start, stop)
            self.assertMapperHasError(mapper, None)
            self.assertEquals(mapper.Retrieve(newTuplePtr), mapper.Retrieve(originalTuplePtr)[start:stop], "bad slice")
            mapper.DecRef(newTuplePtr)
        
        tuplePtr = mapper.Store((0, 1, 2, 3, 4, 5, 6, 7))
        slices = (
            (3, 4), (5, 0), (5, 200), (999, 1000)
        )
        for (start, stop) in slices:
            TestSlice(tuplePtr, start, stop)
            
         
    @WithMapper
    def testPyTuple_GetSlice_error(self, mapper, _):
        self.assertEquals(mapper.PyTuple_GetSlice(mapper.Store(object()), 1, 2), IntPtr.Zero)
        self.assertMapperHasError(mapper, TypeError)



suite = makesuite(
    PyTuple_Type_Test,
    TupleTest,
)

if __name__ == '__main__':
    run(suite)
开发者ID:netcharm,项目名称:ironclad,代码行数:30,代码来源:tupletest.py

示例5: PtrToStructure

        stored = PtrToStructure(methPtr, PyMethodObject)
        self.assertEquals(stored.ob_refcnt, 1)
        self.assertEquals(stored.ob_type, mapper.PyMethod_Type)
        self.assertEquals(stored.im_weakreflist, IntPtr.Zero)
        
        attrs = {
            'im_func': 'foo',
            'im_self': 'bar',
            'im_class': 'baz',
        }
        attrPtrs = []
        for (attr, expected) in attrs.items():
            attrPtr = getattr(stored, attr)
            self.assertEquals(mapper.RefCount(attrPtr), 1)
            mapper.IncRef(attrPtr)
            attrPtrs.append(attrPtr)
            value = mapper.Retrieve(attrPtr)
            self.assertEquals(value, expected)
        
        mapper.DecRef(methPtr)
        for attrPtr in attrPtrs:
            self.assertEquals(mapper.RefCount(attrPtr), 1)
            
        



suite = makesuite(MethodTest)
if __name__ == '__main__':
    run(suite)
开发者ID:IronLanguages,项目名称:ironclad,代码行数:30,代码来源:methodtest.py

示例6: do

            map.CheckBridgePtrs(True)
            del obj1
            del obj2
            return map, ref1, ref2
        map, ref1, ref2 = do()
        gcwait()
        
        self.assertEquals(ref1.IsAlive, False, "failed to GC")
        self.assertEquals(ref2.IsAlive, False, "failed to GC")
    
    
    def testMapOverBridgePtrs(self):
        map, ptr1, obj1, _ = self.getVars()
        __, ptr2, obj2, ___ = self.getVars()
        map.BridgeAssociate(ptr1, obj1)
        map.BridgeAssociate(ptr2, obj2)
        
        ptrs = []
        def MapFunc(ptr):
            ptrs.append(ptr)
        map.MapOverBridgePtrs(PtrFunc(MapFunc))
        self.assertEquals(len(ptrs), 2)
        self.assertEquals(set(ptrs), set([ptr1, ptr2]))
        
        

suite = makesuite(InterestingPtrMapTest)
if __name__ == '__main__':
    run(suite)
开发者ID:IronLanguages,项目名称:ironclad,代码行数:29,代码来源:interestingptrmaptest.py

示例7: dict

        
        d = dict(a=1)
        dPtr = mapper.Store(d)
        mapper.EnsureGIL()
        mapper.PyDict_Next(dPtr, posPtr, keyPtrPtr, valuePtrPtr)
        
        keyPtr = CPyMarshal.ReadPtr(keyPtrPtr)
        valuePtr = CPyMarshal.ReadPtr(valuePtrPtr)
        
        # grab extra references to retard spoilage
        mapper.IncRef(keyPtr)
        mapper.IncRef(valuePtr)
        
        mapper.ReleaseGIL()
        
        # check refcount has dropped back to 1
        self.assertEquals(mapper.RefCount(keyPtr), 1)
        self.assertEquals(mapper.RefCount(valuePtr), 1)





suite = makesuite(
    DictTest,
    PyDict_Next_Test,
)

if __name__ == '__main__':
    run(suite)
开发者ID:netcharm,项目名称:ironclad,代码行数:29,代码来源:dicttest.py

示例8: testBigInteger

    def testBigInteger(self):
        for cls in (NumberI, NumberL, NumberF):
            result = NumberMaker.MakeBigInteger(cls())
            self.assertEquals(isinstance(result, long), True)
            self.assertEquals(result, NUMBER_VALUE)

        self.assertRaises(TypeError, lambda: NumberMaker.MakeBigInteger(object()))

    def testUnsignedBigInteger(self):
        class NumberNeg(object):
            def __int__(self):
                return -1
        self.assertRaises(TypeError, lambda: NumberMaker.MakeUnsignedBigInteger(NumberNeg()))

        result = NumberMaker.MakeBigInteger(NumberF())
        self.assertEquals(isinstance(result, long), True)
        self.assertEquals(result, NUMBER_VALUE)

    def testFloat(self):
        for cls in (NumberI, NumberL, NumberF):
            result = NumberMaker.MakeFloat(cls())
            self.assertEquals(isinstance(result, float), True)
            self.assertEquals(result, NUMBER_VALUE)

        self.assertRaises(TypeError, lambda: NumberMaker.MakeFloat(object()))



suite = makesuite(NumberMakerTest)
if __name__ == '__main__':
    run(suite)
开发者ID:IronLanguages,项目名称:ironclad,代码行数:31,代码来源:numbermakertest.py

示例9: signal

            mapper.PyEval_RestoreThread(x)              # 10
            signal(); wait()
            
            mapper.PyEval_RestoreThread(pe_token)       # 12
            signal(); wait()
            
            mapper.PyGILState_Release(0)                # 14
            signal(); wait()
            
            self.assertFalse(lock.TryAcquire())         # 16
            signal()
            
        t = Thread(ThreadStart(AnotherThread))
        t.Start()
        OneThread()
        t.Join()
    
        mapper.EnsureGIL()



suite = makesuite(
    PyThread_functions_Test,
    PyThreadExceptionTest,
    PyThreadStateTest,
    PyEvalGILThreadTest,
)

if __name__ == '__main__':
    run(suite)
开发者ID:netcharm,项目名称:ironclad,代码行数:30,代码来源:threadtest.py

示例10: PythonMapper_Py_OptimizeFlag_Test

        self.assertEquals(mapper.Retrieve(resultPtr), NotImplemented, "not mapped properly")



class PythonMapper_Py_OptimizeFlag_Test(TestCase):

    @WithMapper
    def testFills(self, mapper, addToCleanUp):
        # TODO: if we set a lower value, numpy will crash inside arr_add_docstring
        # I consider docstrings to be low-priority-enough that it's OK to fudge this
        # for now. also, fixing it would be hard ;).
        flagPtr = Marshal.AllocHGlobal(Marshal.SizeOf(Int32()))
        addToCleanUp(lambda: Marshal.FreeHGlobal(flagPtr))
        mapper.RegisterData("Py_OptimizeFlag", flagPtr)
        
        self.assertEquals(CPyMarshal.ReadInt(flagPtr), 2)



suite = makesuite(
    PythonMapper_CreateDestroy_Test,
    PythonMapper_References_Test,
    PythonMapper_GetFuncPtr_NonApi_Test,
    PythonMapper_NoneTest,
    PythonMapper_NotImplementedTest,
    PythonMapper_Py_OptimizeFlag_Test,
)

if __name__ == '__main__':
    run(suite)
开发者ID:IronLanguages,项目名称:ironclad,代码行数:30,代码来源:pythonmapper_core_test.py

示例11: testPyList_GetSlice_error

    def testPyList_GetSlice_error(self, mapper, _):
        self.assertEquals(mapper.PyList_GetSlice(mapper.Store(object()), 1, 2), IntPtr.Zero)
        self.assertMapperHasError(mapper, TypeError)
        
        
    @WithMapper
    def testPyList_GetItem(self, mapper, _):
        listPtr = mapper.Store([1, 2, 3])
        for i in range(3):
            result = mapper.Retrieve(mapper.PyList_GetItem(listPtr, i))
            self.assertEquals(result, i + 1)
        
        notListPtr = mapper.Store(object())
        self.assertEquals(mapper.PyList_GetItem(notListPtr, 0), IntPtr.Zero)
        self.assertMapperHasError(mapper, TypeError)
    
    
    @WithMapper
    def testPyList_AsTuple(self, mapper, _):
        tPtr = mapper.PyList_AsTuple(mapper.Store([1, 2, 3]))
        self.assertEquals(mapper.Retrieve(tPtr), (1, 2, 3))
        
        
suite = makesuite(
    PyList_Type_Test,
    ListFunctionsTest,
)

if __name__ == '__main__':
    run(suite)
开发者ID:IronLanguages,项目名称:ironclad,代码行数:30,代码来源:listtest.py

示例12: testPyRun_StringFlags_Locals

    @WithMapper
    def testPyRun_StringFlags_Locals(self, mapper, _):
        globals_ = {"foo": "bar"}
        locals_ = {"baz": "qux"}
        resultPtr = mapper.PyRun_StringFlags(
            "baz = 123\nqux = foo",
            int(EvalToken.Py_file_input),
            mapper.Store(globals_),
            mapper.Store(locals_),
            IntPtr.Zero,
        )
        self.assertEquals(resultPtr, mapper._Py_NoneStruct)
        self.assertEquals(globals_["foo"], "bar")
        self.assertEquals(locals_["baz"], 123)
        self.assertEquals(locals_["qux"], "bar")

    @WithMapper
    def testPyRun_StringFlags_Error(self, mapper, _):
        resultPtr = mapper.PyRun_StringFlags(
            "raise ValueError('amoral')", int(EvalToken.Py_file_input), mapper.Store({}), IntPtr.Zero, IntPtr.Zero
        )
        self.assertEquals(resultPtr, IntPtr.Zero)
        self.assertMapperHasError(mapper, ValueError)


suite = makesuite(ExecTest)

if __name__ == "__main__":
    run(suite)
开发者ID:netcharm,项目名称:ironclad,代码行数:29,代码来源:exectest.py

示例13: assertFindsType

    def assertFindsType(self, name):
        class MyPM(PythonApi):
            def fillmethod(self, address):
                WritePyTypeObject(address)
        setattr(MyPM, "Register_" + name, getattr(MyPM, "fillmethod"))
        self.assertDataSetterSetsAndRemembers(MyPM, name, Marshal.SizeOf(PyTypeObject), TestWrotePyTypeObject)


    def testFindsTypes(self):
        for _type in TYPES:
            self.assertFindsType(_type)
        

    def testUninitialisedTypesAreNull(self):
        pa = PythonApi()
        for _type in TYPES:
            self.assertEquals(getattr(pa, _type), IntPtr.Zero, "unexpected")


    def testAddressGetterFailsCleanly(self):
        self.assertEquals(PythonApi().GetFuncPtr("_nonsenx%vQ#*7&"), IntPtr.Zero)


suite = makesuite(
    PythonApiTest,
)

if __name__ == '__main__':
    run(suite)
开发者ID:fdanny,项目名称:ironclad,代码行数:29,代码来源:pythonapitest.py

示例14: read

            text = read(dst, '%s.Generated.cs' % name)
            self.assertNotEquals(text.find(expected), -1, "generated: >>>%s<<<" % text)
        
        assertFinds('CodeSnippets', EXPECTED_SNIPPETS)

        shutil.rmtree(src)
        shutil.rmtree(dst)


SNIPPETS_FILES = {
    'FOO.py': 'some random pile of code',
    'BAR.py': 'some random pile of code, with "double" quotes',
}

EXPECTED_SNIPPETS = """
namespace Ironclad
{
    internal class CodeSnippets
    {
        public const string BAR = @"some random pile of code, with ""double"" quotes";

        public const string FOO = @"some random pile of code";
    }
}
"""


suite = makesuite(GenerateCodeSnippetsTest)
if __name__ == '__main__':
    run(suite)
开发者ID:IronLanguages,项目名称:ironclad,代码行数:30,代码来源:generatecodesnippetstest.py

示例15: testPyMem_Free_NonNull

    
    def testPyMem_Free_NonNull(self):
        frees = []
        mapper = PythonMapper(GetAllocatingTestAllocator([], frees))
        
        ptr = mapper.PyMem_Malloc(123)
        mapper.PyMem_Free(ptr)
        self.assertEquals(frees, [ptr], "did not free")
        mapper.Dispose()
    

    def testPyMem_Free_Null(self):
        frees = []
        mapper = PythonMapper(GetAllocatingTestAllocator([], frees))
        
        mapper.PyMem_Free(IntPtr.Zero)
        self.assertEquals(frees, [], "freed inappropriately")
        mapper.Dispose()


suite = makesuite(
    GetMallocTest('PyMem_Malloc'),
    GetMallocTest('PyObject_Malloc'),
    GetReallocTest('PyMem_Malloc', 'PyMem_Realloc'),
    GetReallocTest('PyObject_Malloc', 'PyObject_Realloc'),
    PyMem_Free_Test, # PyObject_Free is a different matter
)

if __name__ == '__main__':
    run(suite)
开发者ID:netcharm,项目名称:ironclad,代码行数:29,代码来源:memorytest.py


注:本文中的tests.utils.runtest.makesuite函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。