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


Python unittest.decorate函数代码示例

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


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

示例1: test_decorateDecoratedSuite

 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 = unittest.TestCase()
     decoratedTest = unittest.decorate(test, unittest.TestDecorator)
     redecoratedTest = unittest.decorate(decoratedTest, unittest.TestDecorator)
     self.assertTestsEqual(redecoratedTest, unittest.TestDecorator(decoratedTest))
开发者ID:Code-Alliance-Archive,项目名称:oh-mainline,代码行数:9,代码来源:test_tests.py

示例2: run

 def run(self, test):
     """
     Run the test or suite and return a result object.
     """
     test = unittest.decorate(test, ITestCase)
     if self._forceGarbageCollection:
         test = unittest.decorate(
             test, unittest._ForceGarbageCollectionDecorator)
     return self._runWithoutDecoration(test)
开发者ID:antong,项目名称:twisted,代码行数:9,代码来源:runner.py

示例3: run

 def run(self, test):
     """
     Run the test or suite and return a result object.
     """
     result = self._makeResult()
     test = unittest.decorate(test, ITestCase)
     if self._forceGarbageCollection:
         test = unittest.decorate(
             test, unittest._ForceGarbageCollectionDecorator)
     # 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:
         suite.visit(DryRunVisitor(result).markSuccessful)
     elif self.mode == self.DEBUG:
         # open question - should this be self.debug() instead.
         debugger = self._getDebugger()
         oldDir = self._setUpTestdir()
         try:
             self._setUpLogging()
             debugger.runcall(suite.run, result)
         finally:
             self._tearDownLogFile()
             os.chdir(oldDir)
     else:
         oldDir = self._setUpTestdir()
         try:
             self._setUpLogging()
             suite.run(result)
         finally:
             self._tearDownLogFile()
             os.chdir(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=2)
         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
开发者ID:axray,项目名称:dataware.dreamplug,代码行数:50,代码来源:runner.py

示例4: test_decorateSingleTest

 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)
开发者ID:dansgithubuser,项目名称:constructicon,代码行数:8,代码来源:test_tests.py

示例5: __init__

 def __init__(self, tests=(), forceGarbageCollection=False):
     if forceGarbageCollection:
         newTests = []
         for test in tests:
             test = unittest.decorate(test, _ForceGarbageCollectionDecorator)
             newTests.append(test)
         tests = newTests
     suite = LoggedSuite(tests)
     super(TrialSuite, self).__init__([suite])
开发者ID:ssilverek,项目名称:kodb,代码行数:9,代码来源:runner.py

示例6: test_decoratePreservesSuite

 def test_decoratePreservesSuite(self):
     """
     Tests can be in non-standard suites. L{decorate} preserves the
     non-standard suites when it decorates the tests.
     """
     test = unittest.TestCase()
     suite = runner.DestructiveTestSuite([test])
     decorated = unittest.decorate(suite, unittest.TestDecorator)
     self.assertSuitesEqual(decorated, runner.DestructiveTestSuite([unittest.TestDecorator(test)]))
开发者ID:Code-Alliance-Archive,项目名称:oh-mainline,代码行数:9,代码来源:test_tests.py

示例7: test_decorateInPlaceMutatesOriginal

 def test_decorateInPlaceMutatesOriginal(self):
     """
     Calling L{decorate} on a test suite will mutate the original suite.
     """
     test = unittest.TestCase()
     suite = unittest.TestSuite([test])
     decoratedTest = unittest.decorate(suite, unittest.TestDecorator)
     self.assertSuitesEqual(decoratedTest, unittest.TestSuite([unittest.TestDecorator(test)]))
     self.assertSuitesEqual(suite, unittest.TestSuite([unittest.TestDecorator(test)]))
开发者ID:Code-Alliance-Archive,项目名称:oh-mainline,代码行数:9,代码来源:test_tests.py

示例8: test_decorateTestSuite

 def test_decorateTestSuite(self):
     """
     Calling L{decorate} on a test suite will return a test suite with
     each test decorated with the provided decorator.
     """
     test = unittest.TestCase()
     suite = unittest.TestSuite([test])
     decoratedTest = unittest.decorate(suite, unittest.TestDecorator)
     self.assertSuitesEqual(decoratedTest, unittest.TestSuite([unittest.TestDecorator(test)]))
开发者ID:Code-Alliance-Archive,项目名称:oh-mainline,代码行数:9,代码来源:test_tests.py

示例9: test_decorateTestSuiteReferences

    def test_decorateTestSuiteReferences(self):
        """
        When decorating a test suite in-place, the number of references to the
        test objects in that test suite should stay the same.

        Previously, L{unittest.decorate} recreated a test suite, so the
        original suite kept references to the test objects. This test is here
        to ensure the problem doesn't reappear again.
        """
        getrefcount = getattr(sys, 'getrefcount', None)
        if getrefcount is None:
            raise unittest.SkipTest(
                "getrefcount not supported on this platform")
        test = self.TestCase()
        suite = unittest.TestSuite([test])
        count1 = getrefcount(test)
        unittest.decorate(suite, unittest.TestDecorator)
        count2 = getrefcount(test)
        self.assertEqual(count1, count2)
开发者ID:dansgithubuser,项目名称:constructicon,代码行数:19,代码来源:test_tests.py

示例10: test_decorateNestedTestSuite

 def test_decorateNestedTestSuite(self):
     """
     Calling L{decorate} on a test suite with nested suites will return a
     test suite that maintains the same structure, but with all tests
     decorated.
     """
     test = unittest.TestCase()
     suite = unittest.TestSuite([unittest.TestSuite([test])])
     decoratedTest = unittest.decorate(suite, unittest.TestDecorator)
     expected = unittest.TestSuite([unittest.TestSuite([unittest.TestDecorator(test)])])
     self.assertSuitesEqual(decoratedTest, expected)
开发者ID:Code-Alliance-Archive,项目名称:oh-mainline,代码行数:11,代码来源:test_tests.py

示例11: testDoctestError

 def testDoctestError(self):
     from twisted.trial.test import erroneous
     suite = unittest.decorate(
         self.loader.loadDoctests(erroneous), itrial.ITestCase)
     output = self.getOutput(suite)
     path = 'twisted.trial.test.erroneous.unexpectedException'
     for substring in ['1/0', 'ZeroDivisionError',
                       'Exception raised:', path]:
         self.assertSubstring(substring, output)
     self.failUnless(re.search('Fail(ed|ure in) example:', output),
                     "Couldn't match 'Failure in example: ' "
                     "or 'Failed example: '")
     expect = [self.doubleSeparator,
               re.compile(r'\[(ERROR|FAIL)\]: .*' + re.escape(path))]
     self.stringComparison(expect, output.splitlines())
开发者ID:Almad,项目名称:twisted,代码行数:15,代码来源:test_reporter.py

示例12: test_collectCalledWhenTearDownClass

 def test_collectCalledWhenTearDownClass(self):
     """
     test gc.collect is called after tearDownClass.
     """
     test = unittest.TestSuite(
         [TestGarbageCollection.ClassTest('test_1'),
          TestGarbageCollection.ClassTest('test_2')])
     test = unittest.decorate(
         test, unittest._ForceGarbageCollectionDecorator)
     result = reporter.TestResult()
     test.run(result)
     # check that collect gets called after individual tests, and
     # after tearDownClass
     self.failUnlessEqual(
         self._collectCalled,
         ['collect', 'test1', 'collect',
          'collect', 'test2', 'tearDownClass', 'collect'])
开发者ID:axray,项目名称:dataware.dreamplug,代码行数:17,代码来源:test_tests.py

示例13: 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))
开发者ID:ragercool,项目名称:twisted,代码行数:18,代码来源:test_loader.py


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