• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python runner._WritelnDecorator函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_fixture_context_multiple_names_no_common_ancestors

    def test_fixture_context_multiple_names_no_common_ancestors(self):
        stream = _WritelnDecorator(StringIO())
        res = _TextTestResult(stream, 0, 2)
        wd = os.path.join(support, 'ltfn')
        l = loader.TestLoader(workingDir=wd)
        suite = l.loadTestsFromNames(
            ['test_pak1.test_mod',
             'test_pak2:test_two_two',
             'test_mod'])
        print suite
        suite(res)
        res.printErrors()
        print stream.getvalue()
        assert not res.errors, res.errors
        assert not res.failures, res.failures
        assert 'state' in sys.modules, \
               "Context not load state module"
        m = sys.modules['state']
        print "state", m.called

        expect = ['test_pak1.setup',
                  'test_pak1.test_mod.setup',
                  'test_pak1.test_mod.test_one_mod_one',
                  'test_pak1.test_mod.teardown',
                  'test_pak1.teardown',
                  'test_pak2.setup',
                  'test_pak2.test_two_two',
                  'test_pak2.teardown',
                  'test_mod.setup',
                  'test_mod.test_mod',
                  'test_mod.teardown']
        self.assertEqual(m.called, expect, diff(expect, m.called))
开发者ID:ANKIT-KS,项目名称:fjord,代码行数:32,代码来源:test_loader.py


示例2: _make_result

def _make_result(verbose, failfast):
    """Creates a TextTestResult object that writes a stream to a StringIO"""
    stream = _WritelnDecorator(StringIO())
    result = unittest.TextTestResult(stream, True, verbose)
    result.buffer = False
    result.failfast = failfast
    return result
开发者ID:raychorn,项目名称:opencafe,代码行数:7,代码来源:runner_parallel.py


示例3: __init__

    def __init__(
        self,
        stream=None,
        descriptions=True,
        verbosity=1,
        failfast=False,
        buffer=False,
        resultclass=None,
        warnings=None,
        *,
        tb_locals=False,
        process_number=multiprocessing.cpu_count(),
        result_collector_class=None
    ):
        if stream is None:
            stream = sys.stderr
        self.stream = _WritelnDecorator(stream)
        self.descriptions = descriptions
        self.verbosity = verbosity
        self.failfast = failfast
        self.buffer = buffer
        self.tb_locals = tb_locals
        self.warnings = warnings

        self.process_number = process_number

        if resultclass is not None:
            if isinstance(resultclass, collections.Iterable):
                self.resultclass = resultclass
            else:
                self.resultclass = (resultclass,)

        if result_collector_class is not None:
            self.result_collector_class = result_collector_class
开发者ID:BenjaminSchubert,项目名称:NitPycker,代码行数:34,代码来源:runner.py


示例4: makeResult

 def makeResult():
     stream = _WritelnDecorator(StringIO())
     result = resultClass(stream, descriptions=1, verbosity=config.verbosity, config=config)
     plug_result = config.plugins.prepareTestResult(result)
     if plug_result:
         return plug_result
     return result
开发者ID:Praveen-Ramanujam,项目名称:MobRAVE,代码行数:7,代码来源:multiprocess.py


示例5: prepareTestResult

    def prepareTestResult(self, result):
        result.__failures = []
        result.__errors = []
        result.__tests_run = 0
        result.__start_time = time.time()

        result.stream = _WritelnDecorator(open(os.devnull, 'w'))
        self._result = result
开发者ID:gregorynicholas,项目名称:rudolf,代码行数:8,代码来源:rudolf.py


示例6: set_stream

    def set_stream(self, streaming):
        """Set the streaming boolean option to stream TAP directly to stdout.

        The test runner default output will be suppressed in favor of TAP.
        """
        self.stream = _WritelnDecorator(open(os.devnull, "w"))
        _tracker.streaming = streaming
        _tracker.stream = sys.stdout
开发者ID:sunny256,项目名称:tappy,代码行数:8,代码来源:runner.py


示例7: __init__

 def __init__(self, stream=sys.stderr, descriptions=True, verbosity=1,
              failfast=False, buffer=False, resultclass=None):
     self.stream = _WritelnDecorator(stream)
     self.descriptions = descriptions
     self.verbosity = verbosity
     self.failfast = False
     self.buffer = buffer
     if resultclass is not None:
         self.resultclass = resultclass
开发者ID:hendrikvgl,项目名称:RoboCup-Spielererkennung,代码行数:9,代码来源:bit_bots_test_runner.py


示例8: buildReport

 def buildReport(self, add_status):
     subject, summary = self._buildSummary(add_status)
     body = StringIO()
     body.write(summary)
     for test in self.unexpectedSuccesses:
         body.write("UNEXPECTED SUCCESS: %s\n" % self.getDescription(test))
     self.stream = _WritelnDecorator(body)
     self.printErrors()
     return subject, body.getvalue()
开发者ID:Nexedi,项目名称:neoppod,代码行数:9,代码来源:runner.py


示例9: __init__

 def __init__(self, title, verbosity):
     super(NeoTestRunner, self).__init__(
         _WritelnDecorator(sys.stderr), False, verbosity)
     self._title = title
     self.modulesStats = {}
     self.failedImports = {}
     self.run_dict = defaultdict(int)
     self.time_dict = defaultdict(int)
     self.temp_directory = getTempDirectory()
开发者ID:Nexedi,项目名称:neoppod,代码行数:9,代码来源:runner.py


示例10: test_mp_process_args_pickleable

def test_mp_process_args_pickleable():
    test = case.Test(T('runTest'))
    config = Config()
    config.multiprocess_workers = 2
    config.multiprocess_timeout = 0.1
    runner = multiprocess.MultiProcessTestRunner(
        stream=_WritelnDecorator(sys.stdout),
        verbosity=2,
        loaderClass=TestLoader,
        config=config)
    runner.run(test)
开发者ID:Osmose,项目名称:home-snippets-server-lib,代码行数:11,代码来源:test_multiprocess.py


示例11: create_result_object

 def create_result_object(self):
     result = self.resultClass(
         _WritelnDecorator(StringIO()),
         descriptions=1,
         verbosity=self.config.verbosity,
         config=self.config
     )
     plug_result = self.config.plugins.prepareTestResult(result)
     if plug_result:
         return plug_result
     return result
开发者ID:Ragil,项目名称:nose_gevent_multiprocess,代码行数:11,代码来源:nose_gevented_multiprocess.py


示例12: test_load_nonsense_name

    def test_load_nonsense_name(self):
        ctx = os.path.join(support, 'ctx')
        l = loader.TestLoader(workingDir=ctx)
        suite = l.loadTestsFromName('fred!')

        res = _TextTestResult(
            stream=_WritelnDecorator(sys.stdout),
            descriptions=0, verbosity=1)
        suite(res)
        print res.errors
        assert res.errors, "Expected errors but got none"
        assert not res.failures, res.failures
开发者ID:ANKIT-KS,项目名称:fjord,代码行数:12,代码来源:test_loader.py


示例13: test_issue_269

 def test_issue_269(self):
     """Test classes that raise exceptions in __init__ do not stop test run
     """
     wdir = os.path.join(support, 'issue269')
     l = loader.TestLoader(workingDir=wdir)
     suite = l.loadTestsFromName('test_bad_class')
     res = _TextTestResult(
         stream=_WritelnDecorator(sys.stdout),
         descriptions=0, verbosity=1)
     suite(res)
     print res.errors
     self.assertEqual(len(res.errors), 1)
     assert 'raise Exception("pow")' in res.errors[0][1]
开发者ID:ANKIT-KS,项目名称:fjord,代码行数:13,代码来源:test_loader.py


示例14: __init__

 def __init__(self, stream=None, descriptions=True, verbosity=1,
              failfast=False, buffer=False, resultclass=None,
              warnings=None):
     if stream is None:
         stream = sys.stderr
     self.stream = runner._WritelnDecorator(stream)
     self.descriptions = descriptions
     self.verbosity = verbosity
     self.failfast = failfast
     self.buffer = buffer
     self.warnings = warnings
     if resultclass is not None:
         self.resultclass = resultclass
开发者ID:lecnim,项目名称:cutest.py,代码行数:13,代码来源:cutest.py


示例15: test_mp_process_args_pickleable

def test_mp_process_args_pickleable():
    # TODO(Kumar) this test needs to be more succint.
    # If you start seeing it timeout then perhaps we need to skip it again.
    # raise SkipTest('this currently gets stuck in poll() 90% of the time')
    test = case.Test(T('runTest'))
    config = Config()
    config.multiprocess_workers = 2
    config.multiprocess_timeout = 5
    runner = multiprocess.MultiProcessTestRunner(
        stream=_WritelnDecorator(sys.stdout),
        verbosity=10,
        loaderClass=TestLoader,
        config=config)
    runner.run(test)
开发者ID:ANKIT-KS,项目名称:fjord,代码行数:14,代码来源:test_multiprocess.py


示例16: test_failed_import_module_name

    def test_failed_import_module_name(self):
        ctx = os.path.join(support, 'ctx')
        l = loader.TestLoader(workingDir=ctx)
        suite = l.loadTestsFromName('no_such_module')

        res = _TextTestResult(
            stream=_WritelnDecorator(sys.stdout),
            descriptions=0, verbosity=1)
        suite(res)
        print res.errors
        res.printErrors()
        assert res.errors, "Expected errors but got none"
        assert not res.failures, res.failures
        err = res.errors[0][0].test.exc_class
        assert err is ImportError, \
            "Expected import error, got %s" % err
开发者ID:ANKIT-KS,项目名称:fjord,代码行数:16,代码来源:test_loader.py


示例17: test_failed_import

    def test_failed_import(self):
        ctx = os.path.join(support, 'ctx')
        l = loader.TestLoader(workingDir=ctx)
        suite = l.loadTestsFromName('no_such_module.py')

        res = _TextTestResult(
            stream=_WritelnDecorator(sys.stdout),
            descriptions=0, verbosity=1)
        suite(res)

        print res.errors
        res.printErrors()
        assert res.errors, "Expected errors but got none"
        assert not res.failures, res.failures
        assert res.testsRun == 1, \
               "Expected to run 1 tests but ran %s" % res.testsRun
开发者ID:ANKIT-KS,项目名称:fjord,代码行数:16,代码来源:test_loader.py


示例18: test_generator_with_closure

    def test_generator_with_closure(self):
        """Test that a generator test can employ a closure

        Issue #3. If the generator binds early, the last value
        of the closure will be seen for each generated test and
        the tests will fail.
        """
        gen = os.path.join(support, 'gen')
        l = loader.TestLoader(workingDir=gen)
        suite = l.loadTestsFromName('test')
        res = _TextTestResult(
            stream=_WritelnDecorator(sys.stdout),
            descriptions=0, verbosity=1)
        suite(res)
        assert not res.errors
        self.assertEqual(res.testsRun, 5)
开发者ID:ANKIT-KS,项目名称:fjord,代码行数:16,代码来源:test_loader.py


示例19: test_prepare_patches_result

    def test_prepare_patches_result(self):
        stream = _WritelnDecorator(StringIO())
        res = _TextTestResult(stream, 0, 1)
        sk = Skip()
        sk.prepareTestResult(res)
        res._orig_addError
        res._orig_printErrors
        res._orig_wasSuccessful
        res.skipped
        self.assertEqual(res.errorClasses,
                         {SkipTest: (res.skipped, 'SKIP', False)})

        # result w/out print works too
        res = unittest.TestResult()
        sk = Skip()
        sk.prepareTestResult(res)
        res._orig_addError
        res.skipped
        self.assertEqual(res.errorClasses,
                         {SkipTest: (res.skipped, 'SKIP', False)})
开发者ID:ANKIT-KS,项目名称:fjord,代码行数:20,代码来源:test_skip_plugin.py


示例20: test_deprecated_output

    def test_deprecated_output(self):
        class TC(unittest.TestCase):
            def test(self):
                raise DeprecatedTest('deprecated me')

        stream = _WritelnDecorator(StringIO())
        res = _TextTestResult(stream, 0, 1)
        sk = Deprecated()
        sk.prepareTestResult(res)

        test = TC('test')
        test(res)
        assert not res.errors, "Deprecated was not caught: %s" % res.errors
        assert res.deprecated            

        res.printErrors()
        out = stream.getvalue()
        assert out
        assert out.strip() == "D"
        assert res.wasSuccessful()
开发者ID:GaloisInc,项目名称:echronos,代码行数:20,代码来源:test_deprecated_plugin.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python suite.TestSuite类代码示例发布时间:2022-05-27
下一篇:
Python result.TestResult类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap