Here are the examples of the python api twisted.trial.unittest._iterateTests taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
6 Examples
3
Example 1
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
3
Example 2
def test_iterateTestCase(self):
"""
L{_iterateTests} on a single test case returns a list containing that
test case.
"""
test = self.TestCase()
self.assertEqual([test], list(unittest._iterateTests(test)))
3
Example 3
def test_iterateSingletonTestSuite(self):
"""
L{_iterateTests} on a test suite that contains a single test case
returns a list containing that test case.
"""
test = self.TestCase()
suite = runner.TestSuite([test])
self.assertEqual([test], list(unittest._iterateTests(suite)))
3
Example 4
def test_iterateNestedTestSuite(self):
"""
L{_iterateTests} returns tests that are in nested test suites.
"""
test = self.TestCase()
suite = runner.TestSuite([runner.TestSuite([test])])
self.assertEqual([test], list(unittest._iterateTests(suite)))
3
Example 5
Project: SubliminalCollaborator Source File: test_tests.py
Function: test_iterateislefttorightdepthfirst
Function: test_iterateislefttorightdepthfirst
def test_iterateIsLeftToRightDepthFirst(self):
"""
L{_iterateTests} returns tests in left-to-right, depth-first order.
"""
test = self.TestCase()
suite = runner.TestSuite([runner.TestSuite([test]), self])
self.assertEqual([test, self], list(unittest._iterateTests(suite)))
0
Example 6
Project: mythbox Source File: runner.py
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