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


Python runtest.run函数代码示例

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


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

示例1: testPyIter_Next_ExplodingIterator

        self.assertEquals(mapper.PyIter_Next(notIterPtr), IntPtr.Zero, "bad return")
        self.assertMapperHasError(mapper, TypeError)


    @WithMapper
    def testPyIter_Next_ExplodingIterator(self, mapper, _):
        class BorkedException(Exception):
            pass
        def GetNext():
            raise BorkedException("Release the hounds!")
        explodingIterator = (GetNext() for _ in range(3))
        
        iterPtr = mapper.Store(explodingIterator)
        self.assertEquals(mapper.PyIter_Next(iterPtr), IntPtr.Zero, "bad return")
        self.assertNotEquals(mapper.LastException, None, "failed to set exception")
        
        def Raise():
            raise mapper.LastException
        try:
            Raise()
        except BorkedException, e:
            self.assertEquals(str(e), "Release the hounds!", "unexpected message")
        else:
            self.fail("wrong exception")

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

示例2: GetFailedImportTestSuite

import os
import unittest
from tests.utils.runtest import makesuite, run


def GetFailedImportTestSuite(name, e):
    class FailedImportTest(unittest.TestCase):
        def testFailedImport(self):
            raise Exception("could not import %s:\n%s" % (name, e))
    return makesuite(FailedImportTest)

suite = unittest.TestSuite()
for f in os.listdir("tests"):
    if f.endswith("test.py"):
        name = f[:-3]
        try:
            print "adding: tests.%s" % name
            m = __import__("tests.%s" % name)
            suite.addTest(getattr(m, name).suite)
        except Exception, e:
            suite.addTest(GetFailedImportTestSuite(name, e))

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


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