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

Python TestUtilities.bear_test_module函数代码示例

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

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



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

示例1: test_get_filtered_bears

    def test_get_filtered_bears(self):
        sys.argv = ['coala', '-I']

        with bear_test_module():
            local_bears, global_bears = get_filtered_bears(
                None, self.log_printer)

        self.assertEqual(len(local_bears['cli']), TEST_BEARS_COUNT)

        self.assertEqual(
            [str(bear) for bear in local_bears['cli']],
            TEST_BEAR_NAME_REPRS)

        with bear_test_module():
            local_bears, global_bears = get_filtered_bears(
                ['Java'], self.log_printer)

        local_bears['cli'] = _sort_bears(local_bears['cli'])
        global_bears['cli'] = _sort_bears(global_bears['cli'])

        self.assertEqual(len(local_bears['cli']), 3)
        self.assertEqual(
            str(local_bears['cli'][0]),
            "<class 'AspectsGeneralTestBear.AspectsGeneralTestBear'>")
        self.assertEqual(str(local_bears['cli'][1]),
                         "<class 'JavaTestBear.JavaTestBear'>")
        self.assertEqual(str(local_bears['cli'][2]),
                         "<class 'LineCountTestBear.LineCountTestBear'>")
        self.assertEqual(len(global_bears['cli']), 0)
开发者ID:Anmolbansal1,项目名称:coala,代码行数:29,代码来源:ConfigurationGatheringTest.py


示例2: test_filter_by_language_c

 def test_filter_by_language_c(self):
     with bear_test_module():
         retval, stdout, stderr = execute_coala(
             coala.main, 'coala', '-B', '--filter-by', 'language', 'c')
         self.assertEqual(retval, 0)
         # 1 bear plus 1 line holding the closing colour escape sequence.
         self.assertEqual(len(stdout.strip().splitlines()), 2)
开发者ID:CruiseDevice,项目名称:coala,代码行数:7,代码来源:FilterTest.py


示例3: test_fail_acquire_settings

 def test_fail_acquire_settings(self):
     with bear_test_module():
         retval, output = execute_coala(coala.main, 'coala',
                                        '--non-interactive',
                                        '-b', 'SpaceConsistencyTestBear',
                                        '-c', os.devnull)
         self.assertIn('During execution, we found that some', output)
开发者ID:RohanVB,项目名称:coala,代码行数:7,代码来源:coalaCITest.py


示例4: test_filter_by_language_c

 def test_filter_by_language_c(self):
     with bear_test_module():
         retval, stdout, stderr = execute_coala(
             coala.main, 'coala', '-B', '--filter-by', 'language', 'c')
         self.assertEqual(retval, 0)
         self.assertEqual(len(stdout.strip().splitlines()),
                          C_BEARS_COUNT_OUTPUT)
开发者ID:Anmolbansal1,项目名称:coala,代码行数:7,代码来源:FilterTest.py


示例5: test_version_conflict_in_collecting_bears

 def test_version_conflict_in_collecting_bears(self, import_fn, _):
     with bear_test_module():
         import_fn.side_effect = VersionConflict("msg1", "msg2")
         retval, output = execute_coala(coala.main, "coala", "-B")
         self.assertEqual(retval, 13)
         self.assertIn(("There is a conflict in the version of a " "dependency you have installed"), output)
         self.assertIn("pip install msg2", output)  # Check recommendation
开发者ID:CarIosRibeiro,项目名称:coala,代码行数:7,代码来源:coalaTest.py


示例6: test_show_language_bears

 def test_show_language_bears(self):
     with bear_test_module():
         retval, output = execute_coala(
             coala_json.main, 'coala-json', '-B', '-l', 'java')
         self.assertEqual(retval, 0)
         output = json.loads(output)
         self.assertEqual(len(output["bears"]), 2)
开发者ID:AndreaCrotti,项目名称:coala,代码行数:7,代码来源:coalaJSONTest.py


示例7: test_dependency_resolving

    def test_dependency_resolving(self):
        sections = {"test": self.section}
        self.section['bears'] = "DependentBear"
        with simulate_console_inputs("True"), bear_test_module():
            fill_settings(sections, acquire_settings, self.log_printer)

        self.assertEqual(bool(self.section["use_spaces"]), True)
开发者ID:sils1297,项目名称:coala,代码行数:7,代码来源:SectionFillingTest.py


示例8: test_file_cache_proxy_integration

    def test_file_cache_proxy_integration(self, debug=False):
        with bear_test_module():
            with prepare_file(['disk-copy\n'], None) as (_, filename):

                memory_data = 'in-memory\n'
                proxy = FileProxy(filename, None, memory_data)
                proxymap = FileProxyMap([proxy])
                self.cache.set_proxymap(proxymap)

                results, exitcode, file_dicts = run_coala(
                    console_printer=ConsolePrinter(),
                    log_printer=LogPrinter(),
                    arg_list=(
                        '-c', os.devnull,
                        '-f', filename,
                        '-b', 'TestBear',
                    ),
                    autoapply=False,
                    debug=debug,
                    cache=self.cache
                )

                self.assertEqual(exitcode, 0)
                self.assertEqual(len(results), 1)

                # run_coala() output's name is always lower case
                self.assertEqual(file_dicts['cli'][filename.lower()],
                                 (memory_data,))
开发者ID:Anmolbansal1,项目名称:coala,代码行数:28,代码来源:CachingTest.py


示例9: test_show_bears_specified_in_args

 def test_show_bears_specified_in_args(self):
     with bear_test_module():
         retval, stdout, stderr = execute_coala(
             coala.main, 'coala', '-B', '--bears',
             'JavaTestBear', '--no-color')
         self.assertEqual(retval, 0)
         self.assertEqual(stdout.strip(), 'JavaTestBear')
开发者ID:Anmolbansal1,项目名称:coala,代码行数:7,代码来源:ConsoleInteractionTest.py


示例10: test_show_language_bears

 def test_show_language_bears(self):
     with bear_test_module():
         retval, output = execute_coala(
             coala.main, 'coala', '-B', '-l', 'java')
         self.assertEqual(retval, 0)
         # 2 bears plus 1 line holding the closing colour escape sequence
         self.assertEqual(len(output.splitlines()), 3)
开发者ID:justuswilhelm,项目名称:coala,代码行数:7,代码来源:coalaTest.py


示例11: test_section_ordering

    def test_section_ordering(self, debug=False):
        with bear_test_module():
            with prepare_file(['#include <a>'], None) as (lines, filename):
                retval, stdout, stderr = execute_coala(
                        coala.main, 'coala', 'b', 'a',
                        '--non-interactive', '-S',
                        'a.bears=SpaceConsistencyTestBear',
                        'a.files={}'.format(filename),
                        'a.use_spaces=True',
                        'b.bears=SpaceConsistencyTestBear',
                        'b.files={}'.format(filename),
                        'b.use_spaces=True',
                        '-c', os.devnull,
                        debug=debug)
                stdout_list = stdout.splitlines(True)
                self.assertEqual('Executing section b...\n', stdout_list[0])
                self.assertEqual('Executing section a...\n', stdout_list[1])

                retval, stdout, stderr = execute_coala(
                        coala.main, 'coala', 'a', 'b',
                        '--non-interactive', '-S',
                        'a.bears=SpaceConsistencyTestBear',
                        'a.files={}'.format(filename),
                        'a.use_spaces=True',
                        'b.bears=SpaceConsistencyTestBear',
                        'b.files={}'.format(filename),
                        'b.use_spaces=True',
                        '-c', os.devnull,
                        debug=debug)
                stdout_list = stdout.splitlines(True)
                self.assertEqual('Executing section a...\n', stdout_list[0])
                self.assertEqual('Executing section b...\n', stdout_list[1])
开发者ID:Anmolbansal1,项目名称:coala,代码行数:32,代码来源:coalaCITest.py


示例12: test_fill_settings_section_match_with_conflicts

    def test_fill_settings_section_match_with_conflicts(self):
        self.section = Section('test1')
        self.section["files"] = "hello.py"
        sections = {'test1': self.section}

        self.section.append(Setting('bears', 'BearC'))

        with simulate_console_inputs("False") as generator, \
                bear_test_module(), retrieve_stdout() as sio:
            with generate_files([".editorconfig", "hello.py"],
                                [editorconfig_4, "pass"],
                                self.project_dir):
                extracted_info = collect_info(self.project_dir)
                local_bears, global_bears = fill_settings(
                    sections, acquire_settings, self.log_printer,
                    fill_section_method=fill_section,
                    extracted_info=extracted_info)

                self.assertEqual(len(local_bears['test1']), 1)
                self.assertEqual(len(global_bears['test1']), 0)

                prompt_msg = (
                    'coala-quickstart has detected multiple potential values '
                    'for the setting "use_spaces"')
                self.assertIn(prompt_msg, sio.getvalue())
                self.assertEqual(generator.last_input, 0)

        self.assertEqual(bool(self.section['use_spaces']), False)
开发者ID:coala-analyzer,项目名称:coala-quickstart,代码行数:28,代码来源:SettingsFillingTest.py


示例13: test_filter_bears_ci_mode

    def test_filter_bears_ci_mode(self):
        sys.argv.append('--ci')
        with bear_test_module():
            languages = []
            res_1 = filter_relevant_bears(
                languages, self.printer, self.arg_parser, {})

            res_2 = []
            with generate_files(context_filenames,
                                context_file_contents,
                                self.project_dir):
                with simulate_console_inputs("Yes") as generator:
                    extracted_info = collect_info(self.project_dir)
                    res_2 = filter_relevant_bears(languages,
                                                  self.printer,
                                                  self.arg_parser,
                                                  extracted_info)
                    # Make sure there was no prompt
                    self.assertEqual(generator.last_input, -1)

            # The NonOptionalSettingBear is not selected due to non-optional
            # setting value in non-interactive mode.
            additional_bears_by_lang = {
                "All": []
            }
            for lang in res_1:
                additional_bears = [bear.name for bear in res_2[lang]
                                    if bear not in res_1[lang]]
                for bear in additional_bears_by_lang[lang]:
                    self.assertIn(bear, additional_bears)
开发者ID:coala-analyzer,项目名称:coala-quickstart,代码行数:30,代码来源:BearsTest.py


示例14: test_filter_relevant_bears_gruntfile_present

    def test_filter_relevant_bears_gruntfile_present(self):
        # Reset the IMPORTANT_BEARS_LIST
        import coala_quickstart.generation.Bears as Bears
        Bears.IMPORTANT_BEARS_LIST = {
            "JavaScript": "DoesNotExistBear",
            "Python": "DoesNotExistAsWellBear"
        }

        sys.argv.append('--no-filter-by-capabilities')

        with bear_test_module():
            languages = [('JavaScript', 70), ('Python', 20)]
            res = {}
            with generate_files(["Gruntfile.js"],
                                [gruntfile],
                                self.project_dir) as gen_files:
                extracted_info = collect_info(self.project_dir)
                res = filter_relevant_bears(languages,
                                            self.printer,
                                            self.arg_parser,
                                            extracted_info)
            expected_results = {
                "JavaScript": set(["SomeLinterBear"]),
            }
            for lang, lang_bears in expected_results.items():
                for bear in lang_bears:
                    res_bears = [b.name for b in res[lang]]
                    self.assertIn(bear, res_bears)
开发者ID:coala-analyzer,项目名称:coala-quickstart,代码行数:28,代码来源:BearsTest.py


示例15: test_filter_relevant_bears_with_capabilities

    def test_filter_relevant_bears_with_capabilities(self):
        # Clear the IMPORTANT_BEARS_LIST
        import coala_quickstart.generation.Bears as Bears
        Bears.IMPORTANT_BEARS_LIST = {}

        with bear_test_module():
            languages = []
            capability_to_select = 'Smell'
            cap_number = (
                sorted(ALL_CAPABILITIES).index(capability_to_select) + 1)
            res = []
            with simulate_console_inputs('1000', str(cap_number)) as generator:
                res = filter_relevant_bears(languages,
                                            self.printer,
                                            self.arg_parser,
                                            {})
                # 1000 was not a valid option, so there will be two prompts
                self.assertEqual(generator.last_input, 1)

            expected_results = {
                "All": set(["SmellCapabilityBear"])
            }
            for lang, lang_bears in expected_results.items():
                for bear in lang_bears:
                    res_bears = [b.name for b in res[lang]]
                    self.assertIn(bear, res_bears)
开发者ID:coala-analyzer,项目名称:coala-quickstart,代码行数:26,代码来源:BearsTest.py


示例16: test_caching_multi_results

    def test_caching_multi_results(self):
        """
        Integration test to assert that results are not dropped when coala is
        ran multiple times with caching enabled and one section yields a result
        and second one doesn't.
        """
        filename = 'tests/misc/test_caching_multi_results/'
        with bear_test_module():
            with simulate_console_inputs('n'):
                retval, stdout, stderr = execute_coala(
                   coala.main,
                   'coala',
                   '-c', filename + '.coafile',
                   '-f', filename + 'test.py')
                self.assertIn('This file has', stdout)
                self.assertIn(
                    'Implicit \'Default\' section inheritance is deprecated',
                    stderr)

            retval, stdout, stderr = execute_coala(
               coala.main,
               'coala',
               '--non-interactive', '--no-color',
               '-c', filename + '.coafile',
               '-f', filename + 'test.py')
            self.assertIn('This file has', stdout)
            self.assertEqual(2, len(stderr.splitlines()))
            self.assertIn(
                'LineCountTestBear: This result has no patch attached.',
                stderr)
            self.assertIn(
                'Implicit \'Default\' section inheritance is deprecated',
                stderr)
开发者ID:Anmolbansal1,项目名称:coala,代码行数:33,代码来源:CachingTest.py


示例17: test_fail_acquire_settings

 def test_fail_acquire_settings(self):
     with bear_test_module():
         retval, output = execute_coala(coala.main, 'coala', '--json',
                                        '-c', os.devnull,
                                        '-b', 'SpaceConsistencyTestBear')
         self.assertIn('During execution, we found that some',
                       output, 'Missing settings not logged')
开发者ID:justuswilhelm,项目名称:coala,代码行数:7,代码来源:coalaJSONTest.py


示例18: test_get_all_bears_names

 def test_get_all_bears_names(self):
     with bear_test_module():
         names = get_all_bears_names()
         assert isinstance(names, list)
         self.assertSetEqual(
             set(names),
             set(TEST_BEAR_NAMES))
开发者ID:Anmolbansal1,项目名称:coala,代码行数:7,代码来源:CollectorsTest.py


示例19: test_run_coala_no_autoapply

    def test_run_coala_no_autoapply(self, debug=False):
        with bear_test_module():
            with prepare_file(['#fixme  '], None) as (lines, filename):
                self.assertEqual(
                    1,
                    len(run_coala(
                        console_printer=ConsolePrinter(),
                        log_printer=LogPrinter(),
                        arg_list=(
                            '-c', os.devnull,
                            '-f', filename,
                            '-b', 'SpaceConsistencyTestBear',
                            '--apply-patches',
                            '-S', 'use_spaces=yeah'
                        ),
                        autoapply=False,
                        debug=debug
                    )[0]['cli'])
                )

                self.assertEqual(
                    0,
                    len(run_coala(
                        console_printer=ConsolePrinter(),
                        log_printer=LogPrinter(),
                        arg_list=(
                            '-c', os.devnull,
                            '-f', filename,
                            '-b', 'SpaceConsistencyTestBear',
                            '--apply-patches',
                            '-S', 'use_spaces=yeah'
                        ),
                        debug=debug
                    )[0]['cli'])
                )
开发者ID:Anmolbansal1,项目名称:coala,代码行数:35,代码来源:coalaTest.py


示例20: test_coala_no_unexpected_warnings

    def test_coala_no_unexpected_warnings(self):
        with bear_test_module():
            with prepare_file(['#fixme'], None) as (lines, filename):
                retval, stdout, stderr = execute_coala(
                    coala.main, 'coala')
                errors = filter(bool, stderr.split('\n'))
                errors = list(errors)

                unexpected = errors.copy()

                expected = [
                    err for err in unexpected
                    if "Implicit 'Default' section inheritance" in err]
                self.assertNotEqual([], expected)
                # Filter them out
                unexpected = [err for err in unexpected
                              if err not in expected]

                # These errors depend on the state of the host, so ignore them
                ignored = [
                    err for err in unexpected
                    if re.search("No bears matching '.*' were found", err)]

                # Filter them out
                unexpected = [err for err in unexpected if err not in ignored]

                self.assertEqual([], unexpected)
                self.assertEqual(
                    retval, 0,
                    'coala must return zero when there are no errors;'
                    ' errors={errors}'.format(errors=list(errors)))
开发者ID:Anmolbansal1,项目名称:coala,代码行数:31,代码来源:coalaTest.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python TestUtilities.execute_coala函数代码示例发布时间:2022-05-27
下一篇:
Python LocalBearTestHelper.verify_local_bear函数代码示例发布时间: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