本文整理汇总了Python中twisted.trial.unittest._iterateTests函数的典型用法代码示例。如果您正苦于以下问题:Python _iterateTests函数的具体用法?Python _iterateTests怎么用?Python _iterateTests使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_iterateTests函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_iterateIsLeftToRightDepthFirst
def test_iterateIsLeftToRightDepthFirst(self):
"""
L{_iterateTests} returns tests in left-to-right, depth-first order.
"""
test = unittest.TestCase()
suite = runner.TestSuite([runner.TestSuite([test]), self])
self.assertEqual([test, self], list(unittest._iterateTests(suite)))
示例2: test_iterateNestedTestSuite
def test_iterateNestedTestSuite(self):
"""
L{_iterateTests} returns tests that are in nested test suites.
"""
test = unittest.TestCase()
suite = runner.TestSuite([runner.TestSuite([test])])
self.assertEqual([test], list(unittest._iterateTests(suite)))
示例3: test_iterateTestCase
def test_iterateTestCase(self):
"""
L{_iterateTests} on a single test case returns a list containing that
test case.
"""
test = unittest.TestCase()
self.assertEqual([test], list(unittest._iterateTests(test)))
示例4: runTests
def runTests():
testCases = iter(list(_iterateTests(suite)))
workerDeferreds = []
for worker in ampWorkers:
workerDeferreds.append(self._driveWorker(worker, result, testCases, cooperate=cooperate))
return DeferredList(workerDeferreds, consumeErrors=True, fireOnOneErrback=True)
示例5: testNames
def testNames(tests):
"""
Return the id of each test within the given test suite or case.
"""
names = []
for test in unittest._iterateTests(tests):
names.append(test.id())
return names
示例6: test_iterateSingletonTestSuite
def test_iterateSingletonTestSuite(self):
"""
L{_iterateTests} on a test suite that contains a single test case
returns a list containing that test case.
"""
test = unittest.TestCase()
suite = runner.TestSuite([test])
self.assertEqual([test], list(unittest._iterateTests(suite)))
示例7: _runWithoutDecoration
def _runWithoutDecoration(self, test):
"""
Private helper that runs the given test but doesn't decorate it.
"""
result = self._makeResult()
# decorate the suite with reactor cleanup and log starting
# This should move out of the runner and be presumed to be
# present
suite = TrialSuite([test])
startTime = time.time()
if self.mode == self.DRY_RUN:
for single in unittest._iterateTests(suite):
result.startTest(single)
result.addSuccess(single)
result.stopTest(single)
else:
if self.mode == self.DEBUG:
# open question - should this be self.debug() instead.
debugger = self._getDebugger()
run = lambda: debugger.runcall(suite.run, result)
else:
run = lambda: suite.run(result)
oldDir = self._setUpTestdir()
try:
self._setUpLogFile()
run()
finally:
self._tearDownLogFile()
self._tearDownTestdir(oldDir)
endTime = time.time()
done = getattr(result, 'done', None)
if done is None:
warnings.warn(
"%s should implement done() but doesn't. Falling back to "
"printErrors() and friends." % reflect.qual(result.__class__),
category=DeprecationWarning, stacklevel=3)
result.printErrors()
result.writeln(result.separator)
result.writeln('Ran %d tests in %.3fs', result.testsRun,
endTime - startTime)
result.write('\n')
result.printSummary()
else:
result.done()
return result
示例8: loadSortedPackages
def loadSortedPackages(self, sorter=runner.name):
"""
Verify that packages are loaded in the correct order.
"""
import uberpackage
self.loader.sorter = sorter
suite = self.loader.loadPackage(uberpackage, recurse=True)
# XXX: Work around strange, unexplained Zope crap.
# jml, 2007-11-15.
suite = unittest.decorate(suite, ITestCase)
resultingTests = list(unittest._iterateTests(suite))
manifest = list(self._trialSortAlgorithm(sorter))
for number, (manifestTest, actualTest) in enumerate(zip(manifest, resultingTests)):
self.assertEqual(
manifestTest.name, actualTest.id(), "#%d: %s != %s" % (number, manifestTest.name, actualTest.id())
)
self.assertEqual(len(manifest), len(resultingTests))