Here are the examples of the python api twisted.trial.unittest.TestDecorator taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
5 Examples
3
Example 1
Project: SubliminalCollaborator Source File: test_tests.py
def test_usesAdaptedReporterWithRun(self):
"""
For decorated tests, C{run} uses a result adapter that preserves the
test decoration for calls to C{addError}, C{startTest} and the like.
See L{reporter._AdaptedReporter}.
"""
test = self.TestCase()
decoratedTest = unittest.TestDecorator(test)
result = LoggingReporter()
decoratedTest.run(result)
self.assertTestsEqual(result.test, decoratedTest)
3
Example 2
Project: SubliminalCollaborator Source File: test_tests.py
def test_usesAdaptedReporterWithCall(self):
"""
For decorated tests, C{__call__} uses a result adapter that preserves
the test decoration for calls to C{addError}, C{startTest} and the
like.
See L{reporter._AdaptedReporter}.
"""
test = self.TestCase()
decoratedTest = unittest.TestDecorator(test)
result = LoggingReporter()
decoratedTest(result)
self.assertTestsEqual(result.test, decoratedTest)
3
Example 3
def test_decorateSingleTest(self):
"""
Calling L{decorate} on a single test case returns the test case
decorated with the provided decorator.
"""
test = self.TestCase()
decoratedTest = unittest.decorate(test, unittest.TestDecorator)
self.assertTestsEqual(unittest.TestDecorator(test), decoratedTest)
3
Example 4
def test_decorateDecoratedSuite(self):
"""
Calling L{decorate} on a test suite with already-decorated tests
decorates all of the tests in the suite again.
"""
test = self.TestCase()
decoratedTest = unittest.decorate(test, unittest.TestDecorator)
redecoratedTest = unittest.decorate(decoratedTest,
unittest.TestDecorator)
self.assertTestsEqual(redecoratedTest,
unittest.TestDecorator(decoratedTest))
3
Example 5
def test_decoratePreservesSuite(self):
"""
Tests can be in non-standard suites. L{decorate} preserves the
non-standard suites when it decorates the tests.
"""
test = self.TestCase()
suite = runner.DestructiveTestSuite([test])
decorated = unittest.decorate(suite, unittest.TestDecorator)
self.assertSuitesEqual(
decorated,
runner.DestructiveTestSuite([unittest.TestDecorator(test)]))