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

Python runner._WritelnDecorator函数代码示例

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

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



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

示例1: test_sql_test_case_with_discovery_queries

    def test_sql_test_case_with_discovery_queries(self):
        tinc_test_loader = tinctest.TINCTestLoader()
        pwd = os.path.dirname(inspect.getfile(self.__class__))
        test_dir = os.path.join(pwd, 'sql_pattern')
        tinc_test_suite = tinc_test_loader.discover(start_dirs = [test_dir], patterns = ['sql_pattern.py'],
                                                    top_level_dir = None, query_handler = TINCDiscoveryQueryHandler(['method=test_functional_*']))

        test_case = None
        test_result = None
            
        with closing(_WritelnDecorator(StringIO())) as buffer:
            tinc_test_runner = TINCTestRunner(stream = buffer, descriptions = True, verbosity = 1)
            test_result = tinc_test_runner.run(tinc_test_suite)
            self.assertEqual(test_result.testsRun, 6)
            self.assertEqual(len(test_result.skipped), 6)


        # Queries using metadata from sql files
        tinc_test_loader = tinctest.TINCTestLoader()
        pwd = os.path.dirname(inspect.getfile(self.__class__))
        test_dir = os.path.join(pwd, 'sql_pattern')
        tinc_test_suite = tinc_test_loader.discover(start_dirs = [test_dir], patterns = ['sql_pattern.py'],
                                                    top_level_dir = None,
                                                    query_handler = TINCDiscoveryQueryHandler(['method=test_functional_* and tags != long']))

        test_case = None
        test_result = None
            
        with closing(_WritelnDecorator(StringIO())) as buffer:
            tinc_test_runner = TINCTestRunner(stream = buffer, descriptions = True, verbosity = 1)
            test_result = tinc_test_runner.run(tinc_test_suite)
            self.assertEqual(test_result.testsRun, 3)
            self.assertEqual(len(test_result.skipped), 3)
开发者ID:PengJi,项目名称:gpdb-comments,代码行数:33,代码来源:test_sql_pattern.py


示例2: test_module_import_failures_with_dryrun

    def test_module_import_failures_with_dryrun(self):
        """
        Test that module import failures are reported correctly in dryrun
        """
        tinc_test_loader = tinctest.TINCTestLoader()
        pwd = os.path.dirname(inspect.getfile(self.__class__))
        test_dir = os.path.join(pwd, 'mocktests')
        tinc_test_suite = tinc_test_loader.discover(start_dirs = [test_dir],
                                                    patterns = ['dryrun_test_invalid_import.py'],
                                                    top_level_dir = test_dir,
                                                    dryrun=True
                                                    )


        
        with closing(_WritelnDecorator(StringIO())) as buffer:
            tinc_test_result = tinctest.TINCTestResultSet(buffer, True, 1)
            tinc_test_suite.run(tinc_test_result)
            self.assertEquals(tinc_test_result.testsRun, 1)
            # This variable should be 0 even after the tests are run in the dryrun mode since
            # we do not expect to run the test code
            self.assertEquals(tinctest.test.dryrun.tests_run_count, 0)

            self.assertEquals(len(tinc_test_result.errors),1)

            test_instance = tinc_test_result.errors[0][0]
            traceback_msg = tinc_test_result.errors[0][1]
            self.assertEquals(test_instance.__class__.__name__, "TINCModuleImportFailure")
            self.assertTrue("Failed to import test module" in traceback_msg)
开发者ID:50wu,项目名称:gpdb,代码行数:29,代码来源:test_dryrun.py


示例3: test_failure

 def test_failure(self):
     test_case = MockConcurrencyTestCase('test_failure')
     test_case.__class__.__unittest_skip__ = False
     with closing(_WritelnDecorator(StringIO())) as buffer:
         test_result = TINCTextTestResult(buffer, True, 1)
         test_case.run(test_result)
     self.assertEqual(len(test_result.failures), 1)
开发者ID:PengJi,项目名称:gpdb-comments,代码行数:7,代码来源:test_concurrency_test_case.py


示例4: test_skipped_tests_with_dryrun

    def test_skipped_tests_with_dryrun(self):
        """
        Test that dryrun reports tests with skip metadata without running setup class / setup / teardownclass/ teardown fixtures
        """
        tinc_test_loader = tinctest.TINCTestLoader()
        pwd = os.path.dirname(inspect.getfile(self.__class__))
        test_dir = os.path.join(pwd, 'mocktests')

        tinc_test_suite = tinc_test_loader.discover(start_dirs = [test_dir],
                                                    patterns = ['dryrun_test_sample2.py'],
                                                    top_level_dir = test_dir,
                                                    dryrun=True
                                                    )

        with closing(_WritelnDecorator(StringIO())) as buffer:
            tinc_test_result = tinctest.TINCTestResultSet(buffer, True, 1)
            tinc_test_suite.run(tinc_test_result)
            self.assertEquals(tinc_test_result.testsRun, 3)
            # This variable should be 0 even after the tests are run in the dryrun mode since
            # we do not expect to run the test code
            self.assertEquals(tinctest.test.dryrun.tests_run_count, 0)

            #test03 in the result should be skipped correctly
            self.assertEquals(len(tinc_test_result.skipped),1)
            self.assertEquals(tinc_test_result.skipped[0][1],
                              "just skipping")
开发者ID:50wu,项目名称:gpdb,代码行数:26,代码来源:test_dryrun.py


示例5: test_run_test_with_data_provider_complicated

 def test_run_test_with_data_provider_complicated(self):
     tinc_test_loader = tinctest.TINCTestLoader()
     tinc_test_suite = tinc_test_loader.loadTestsFromName('tinctest.test.test_data_provider.MockTINCTestCaseWithDataProviderComplicated.test_with_data_provider_complicated')
     with closing(_WritelnDecorator(StringIO())) as buffer:
         tinc_test_result = tinctest.TINCTestResultSet(buffer, True, 1)
         tinc_test_suite.run(tinc_test_result)
         # This should have run two tests
         self.assertEquals(tinc_test_result.testsRun, 6)
开发者ID:50wu,项目名称:gpdb,代码行数:8,代码来源:test_data_provider.py


示例6: test_run_test_with_data_provider_no_expand

 def test_run_test_with_data_provider_no_expand(self):
     tinc_test_loader = tinctest.TINCTestLoader()
     tinc_test_suite = tinc_test_loader.loadTestsFromName('tinctest.test.test_data_provider.MockTINCTestCaseWithDataProvider.test_with_data_provider', expand = False)
     with closing(_WritelnDecorator(StringIO())) as buffer:
         tinc_test_result = tinctest.TINCTestResultSet(buffer, True, 1)
         tinc_test_suite.run(tinc_test_result)
         # This should have run one test, since expand is False
         self.assertEquals(tinc_test_result.testsRun, 1)
开发者ID:50wu,项目名称:gpdb,代码行数:8,代码来源:test_data_provider.py


示例7: test_runner

 def test_runner(self):
     test_loader = tinctest.TINCTestLoader()
     tinc_test_suite = test_loader.loadTestsFromName('tinctest.models.concurrency.test.test_concurrency_test_case.MockConcurrencyTestCase')
     for test in tinc_test_suite._tests:
         if not 'test_skip' in test.name:
             test.__class__.__unittest_skip__ = False
     with closing(_WritelnDecorator(StringIO())) as buffer:
         tinc_test_runner = TINCTestRunner(stream = buffer, descriptions = True, verbosity = 1)
         tinc_test_runner.run(tinc_test_suite)
开发者ID:PengJi,项目名称:gpdb-comments,代码行数:9,代码来源:test_concurrency_test_case.py


示例8: test_error

 def test_error(self):
     tinc_test_case = MockTINCTestCaseForResults('test_error')
     tinc_test_case.__class__.__unittest_skip__ = False
     with closing(_WritelnDecorator(StringIO())) as buffer:
         # Run tinc test with verbosity=2 similar to Pulse
         tinc_test_result = tinctest.TINCTextTestResult(buffer, descriptions=True, verbosity=2)
         tinc_test_case.run(tinc_test_result)
         text = buffer.getvalue()
     match_object = self.p.match(text)
     self.assertEqual(match_object.group(1), 'MockTINCTestCaseForResults.test_error')
     self.assertEqual(match_object.group(5), 'ERROR')
开发者ID:PengJi,项目名称:gpdb-comments,代码行数:11,代码来源:test_core.py


示例9: test_suite_construction_with_discover

 def test_suite_construction_with_discover(self):
     tinc_test_loader = tinctest.TINCTestLoader()
     pwd = os.path.dirname(inspect.getfile(self.__class__))
     test_dir = os.path.join(pwd, 'data_provider')
     tinc_test_suite = tinc_test_loader.discover(start_dirs = [test_dir],
                                                 patterns = ['test_*.py'],
                                                 top_level_dir = test_dir)
     with closing(_WritelnDecorator(StringIO())) as buffer:
         tinc_test_result = tinctest.TINCTestResultSet(buffer, True, 1)
         tinc_test_suite.run(tinc_test_result)
         # This should have run 11 tests
         self.assertEquals(tinc_test_result.testsRun, 11)
开发者ID:50wu,项目名称:gpdb,代码行数:12,代码来源:test_data_provider.py


示例10: _discover_and_run_tests

 def _discover_and_run_tests(self, start_dirs, patterns, top_level_dir, query_handler):
     tinc_test_loader = tinctest.TINCTestLoader()
     tinc_test_suite = tinc_test_loader.discover(start_dirs = start_dirs,
                                                 patterns = patterns,
                                                 top_level_dir = None,
                                                 query_handler = query_handler
                                                 )
                                                 
     with closing(_WritelnDecorator(StringIO())) as buffer:
         tinc_test_result = tinctest.TINCTestResultSet(buffer, True, 1)
         tinc_test_suite.run(tinc_test_result)
         return tinc_test_result
开发者ID:50wu,项目名称:gpdb,代码行数:12,代码来源:test_discovery.py


示例11: test_skip

 def test_skip(self):
     tinc_test_case = MockTINCTestCaseForResults('test_skip')
     tinc_test_case.__class__.__unittest_skip__ = False
     with closing(_WritelnDecorator(StringIO())) as buffer:
         tinc_test_result = tinctest.TINCTextTestResult(buffer, True, 1)
         tinc_test_case.run(tinc_test_result)
         text = buffer.getvalue()
     self.assertEqual(tinc_test_result.testsRun, 1)
     self.assertEqual(len(tinc_test_result.failures), 0)
     self.assertEqual(len(tinc_test_result.skipped), 1)
     self.assertEqual(len(tinc_test_result.errors), 0)
     self.assertRegexpMatches(text, 'MockTINCTestCaseForResults.test_skip \.\.\. .* \.\.\. skipped .*')
开发者ID:PengJi,项目名称:gpdb-comments,代码行数:12,代码来源:test_core.py


示例12: test_scenario_with_custom_result_fail

    def test_scenario_with_custom_result_fail(self):
        test_loader = tinctest.TINCTestLoader()
        tinc_test_suite = test_loader.loadTestsFromName('tinctest.models.scenario.test.test_scenario_test_case.MockScenarioTestCaseWithCustomResult.test_with_custom_result_fail')
        for test in tinc_test_suite._tests:
            test.__class__.__unittest_skip__ = False
        with closing(_WritelnDecorator(StringIO())) as buffer:
            tinc_test_runner = TINCTestRunner(stream = buffer, descriptions = True, verbosity = 1)
            tinc_test_runner.run(tinc_test_suite)

        for test in tinc_test_suite._tests:
            if 'test_with_custom_result_fail' in test.name:
                self.assertEqual(test.s, 0)
                self.assertEqual(test.f, 1)
开发者ID:PengJi,项目名称:gpdb-comments,代码行数:13,代码来源:test_scenario_test_case.py


示例13: test_loading_with_decorator_discover

 def test_loading_with_decorator_discover(self):
     tinc_test_loader = tinctest.TINCTestLoader()
     pwd = os.path.dirname(inspect.getfile(self.__class__))
     test_dir = os.path.join(pwd, 'skip_loading')
     tinc_test_suite = tinc_test_loader.discover(start_dirs = [test_dir],
                                                 patterns = ['test_load_with_*.py'],
                                                 top_level_dir = test_dir)
     with closing(_WritelnDecorator(StringIO())) as buffer:
         tinc_test_result = tinctest.TINCTestResultSet(buffer, True, 1)
         tinc_test_suite.run(tinc_test_result)
         # This should have run 2 tests as test_01
         # would have been skipped loading at the base class with decorator
         self.assertEquals(tinc_test_result.testsRun, 2)
开发者ID:PengJi,项目名称:gpdb-comments,代码行数:13,代码来源:test_skip_loading.py


示例14: test_suite_construction_with_discover_and_tinc_queries

 def test_suite_construction_with_discover_and_tinc_queries(self):
     tinc_test_loader = tinctest.TINCTestLoader()
     pwd = os.path.dirname(inspect.getfile(self.__class__))
     test_dir = os.path.join(pwd, 'data_provider')
     query_handler = TINCDiscoveryQueryHandler("tags=tag1")
     tinc_test_suite = tinc_test_loader.discover(start_dirs = [test_dir],
                                                 patterns = ['test_*.py'],
                                                 top_level_dir = test_dir,
                                                 query_handler = query_handler)
     with closing(_WritelnDecorator(StringIO())) as buffer:
         tinc_test_result = tinctest.TINCTestResultSet(buffer, True, 1)
         tinc_test_suite.run(tinc_test_result)
         # This should have filtered 4 tests and hence run 7 tests
         self.assertEquals(tinc_test_result.testsRun, 7)
开发者ID:50wu,项目名称:gpdb,代码行数:14,代码来源:test_data_provider.py


示例15: test_discover_with_invalid_imports

 def test_discover_with_invalid_imports(self):
     tinc_test_loader = tinctest.TINCTestLoader()
     pwd = os.path.dirname(inspect.getfile(self.__class__))
     test_dir = os.path.join(pwd, 'data_provider')
     tinc_test_suite = tinc_test_loader.discover(start_dirs = [test_dir],
                                                 patterns = ['discover_invalid_imports.py'],
                                                 top_level_dir = test_dir)
                                       
     self.assertEquals(len(tinc_test_suite._tests), 1)
     with closing(_WritelnDecorator(StringIO())) as buffer:
         tinc_test_result = tinctest.TINCTestResultSet(buffer, True, 1)
         tinc_test_suite.run(tinc_test_result)
         # This should have thrown a ModuleImportFailure error
         self.assertTrue('ModuleImportFailure' in str(tinc_test_result.errors[0][0]))
开发者ID:PengJi,项目名称:gpdb-comments,代码行数:14,代码来源:test_core.py


示例16: test_execution_with_dryrun

    def test_execution_with_dryrun(self):
        """
        Test that the actual tests are not executed in dryrun mode
        """
        tinc_test_loader = tinctest.TINCTestLoader()
        pwd = os.path.dirname(inspect.getfile(self.__class__))
        test_dir = os.path.join(pwd, 'mocktests')

        
        tinc_test_suite = tinc_test_loader.discover(start_dirs = [test_dir],
                                                    patterns = ['dryrun_test_sample2.py'],
                                                    top_level_dir = test_dir,
                                                    dryrun=True
                                                    )


        with closing(_WritelnDecorator(StringIO())) as buffer:
            tinc_test_result = tinctest.TINCTestResultSet(buffer, True, 1)
            tinc_test_suite.run(tinc_test_result)
            self.assertEquals(tinc_test_result.testsRun, 3)
            # This variable should be 0 even after the tests are run in the dryrun mode since
            # we do not expect to run the test code
            self.assertEquals(tinctest.test.dryrun.tests_run_count, 0)


        #Without dryrun it should have set the variable

        tinc_test_suite = tinc_test_loader.discover(start_dirs = [test_dir],
                                                    patterns = ['dryrun_test_sample2.py'],
                                                    top_level_dir = test_dir
                                                    )
        with closing(_WritelnDecorator(StringIO())) as buffer:
            tinc_test_result = tinctest.TINCTestResultSet(buffer, True, 1)
            tinc_test_suite.run(tinc_test_result)
            self.assertEquals(tinc_test_result.testsRun, 3)
            # tests should have been run and tests_run_count should be incremented
            self.assertEquals(tinctest.test.dryrun.tests_run_count, 8)
开发者ID:50wu,项目名称:gpdb,代码行数:37,代码来源:test_dryrun.py


示例17: test_sql_test_case_discovery_with_pattern_matching

    def test_sql_test_case_discovery_with_pattern_matching(self):
        tinc_test_loader = tinctest.TINCTestLoader()
        pwd = os.path.dirname(inspect.getfile(self.__class__))
        test_dir = os.path.join(pwd, 'sql_pattern')
        tinc_test_suite = tinc_test_loader.discover(start_dirs = [test_dir], patterns = ['sql_pattern.py'],
                                                    top_level_dir = None, query_handler = None)

        test_case = None
        test_result = None
            
        with closing(_WritelnDecorator(StringIO())) as buffer:
            tinc_test_runner = TINCTestRunner(stream = buffer, descriptions = True, verbosity = 1)
            test_result = tinc_test_runner.run(tinc_test_suite)
            self.assertEqual(test_result.testsRun, 12)
            self.assertEqual(len(test_result.skipped), 12)
开发者ID:PengJi,项目名称:gpdb-comments,代码行数:15,代码来源:test_sql_pattern.py


示例18: run_test

 def run_test(self, method_name, skip_expected,
              test_case_prefix = 'tinctest.test.test_version_check.MockTINCTestCaseWithGetVersion'):
     loader = TINCTestLoader()
     tinc_test_suite = loader.loadTestsFromName('%s.%s' %(test_case_prefix, method_name), dryrun=True)
     with closing(_WritelnDecorator(StringIO())) as buffer:
         tinc_test_result = tinctest.TINCTextTestResult(buffer, True, 1)
         tinc_test_suite.run(tinc_test_result)
         text = buffer.getvalue()
     self.assertEqual(tinc_test_result.testsRun, 1)
     self.assertEqual(len(tinc_test_result.failures), 0)
     if skip_expected:
         self.assertEqual(len(tinc_test_result.skipped), 1)
     else:
         self.assertEqual(len(tinc_test_result.skipped), 0)
     self.assertEqual(len(tinc_test_result.errors), 0)
开发者ID:HaozhouWang,项目名称:gpdb,代码行数:15,代码来源:test_version_check.py


示例19: test_skip_when_tag_in_sql_file

 def test_skip_when_tag_in_sql_file(self):
     test_loader = TINCTestLoader()
     test_suite = test_loader.loadTestsFromTestCase(MockSQLTestCaseForSkip)
     test_case = None
     for case in test_suite._tests:
         if case.name == "MockSQLTestCaseForSkip.test_query01":
             test_case = case
     self.assertNotEqual(test_case, None)
     self.assertEqual(test_case.name, "MockSQLTestCaseForSkip.test_query01")
     with closing(_WritelnDecorator(StringIO())) as buffer:
         test_result = TINCTextTestResult(buffer, True, 1)
         test_case.run(test_result)
     self.assertEqual(test_result.testsRun, 1)
     self.assertEqual(len(test_result.failures), 0)
     self.assertEqual(len(test_result.skipped), 1)
     self.assertEqual(len(test_result.errors), 0)
开发者ID:PengJi,项目名称:gpdb-comments,代码行数:16,代码来源:test_sql_test_case.py


示例20: test_sanity_failure

    def test_sanity_failure(self):
        test_loader = tinctest.TINCTestLoader()
        test_suite = test_loader.loadTestsFromName('mpp.models.regress.mpp_tc.regress_mpp_test_case.MockMPPTestCase.test_failure')
        self.assertIsNotNone(test_suite)

        self.assertTrue(len(test_suite._tests), 1)

        for test in test_suite._tests:
            test.__class__.__unittest_skip__ = False

        with closing(_WritelnDecorator(StringIO())) as buffer:
            test_result = tinctest.TINCTextTestResult(buffer, True, 1)
            test_suite.run(test_result)
            self.assertEqual(test_result.testsRun, 1)
            self.assertEqual(len(test_result.errors), 0)
            self.assertEqual(len(test_result.skipped), 0)
            self.assertEqual(len(test_result.failures), 1)
开发者ID:50wu,项目名称:gpdb,代码行数:17,代码来源:regress_mpp_test_case.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python util.safe_repr函数代码示例发布时间:2022-05-27
下一篇:
Python unittest2.TestSuite类代码示例发布时间: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