本文整理汇总了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)
示例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)