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

Python core.Project类代码示例

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

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



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

示例1: test_should_write_pycharm_file

    def test_should_write_pycharm_file(self, os, mock_open):
        project = Project('basedir', name='pybuilder')
        project.set_property('dir_source_main_python', 'src/main/python')
        mock_open.return_value = MagicMock(spec=TYPE_FILE)
        os.path.join.side_effect = lambda first, second: first + '/' + second

        pycharm_generate(project, Mock())

        mock_open.assert_called_with('basedir/.idea/pybuilder.iml', 'w')
        metadata_file = mock_open.return_value.__enter__.return_value
        metadata_file.write.assert_called_with("""<?xml version="1.0" encoding="UTF-8"?>
<!-- This file has been generated by the PyBuilder PyCharm Plugin -->

<module type="PYTHON_MODULE" version="4">
  <component name="NewModuleRootManager">
    <content url="file://$MODULE_DIR$">
      <sourceFolder url="file://$MODULE_DIR$/src/main/python" isTestSource="false" />
    </content>
    <orderEntry type="inheritedJdk" />
    <orderEntry type="sourceFolder" forTests="false" />
  </component>
  <component name="PyDocumentationSettings">
    <option name="myDocStringFormat" value="Plain" />
  </component>
  <component name="TestRunnerService">
    <option name="projectConfiguration" value="Unittests" />
    <option name="PROJECT_TEST_RUNNER" value="Unittests" />
  </component>
</module>
""")
开发者ID:B-Rich,项目名称:pybuilder,代码行数:30,代码来源:pycharm_plugin_tests.py


示例2: RunSonarAnalysisTest

class RunSonarAnalysisTest(TestCase):

    def setUp(self):
        self.project = Project("any-project")
        self.project.version = "0.0.1"
        self.project.set_property("sonarqube_project_key", "project_key")
        self.project.set_property("sonarqube_project_name", "project_name")
        self.project.set_property("dir_source_main_python", "src/main/python")
        self.project.set_property("dir_target", "target")
        self.project.set_property("dir_reports", "target/reports")

    def test_should_build_sonar_runner_for_project(self):
        self.assertEqual(
            build_sonar_runner(self.project).as_string,
            "sonar-runner -Dsonar.projectKey=project_key "
            "-Dsonar.projectName=project_name "
            "-Dsonar.projectVersion=0.0.1 "
            "-Dsonar.sources=src/main/python "
            "-Dsonar.python.coverage.reportPath=target/reports/coverage*.xml")

    @patch("pybuilder.plugins.python.sonarqube_plugin.SonarCommandBuilder.run")
    def test_should_break_build_when_sonar_runner_fails(self, run_sonar_command):
        run_sonar_command.return_value = Mock(exit_code=1)

        self.assertRaises(BuildFailedException, run_sonar_analysis, self.project, Mock())

    @patch("pybuilder.plugins.python.sonarqube_plugin.SonarCommandBuilder.run")
    def test_should_not_break_build_when_sonar_runner_succeeds(self, run_sonar_command):
        run_sonar_command.return_value = Mock(exit_code=0)

        run_sonar_analysis(self.project, Mock())
开发者ID:0xD3ADB33F,项目名称:pybuilder,代码行数:31,代码来源:sonarqube_plugin_tests.py


示例3: ProjectPackageDataTests

class ProjectPackageDataTests(unittest.TestCase):
    def setUp(self):
        self.project = Project(basedir="/imaginary", name="Unittest")

    def test_should_raise_exception_when_package_name_not_given(self):
        self.assertRaises(ValueError, self.project.include_file, None, "spam")

    def test_should_raise_exception_when_filename_not_given(self):
        self.assertRaises(
            ValueError, self.project.include_file, "my_package", None)

    def test_should_raise_exception_when_package_name_is_empty_string(self):
        self.assertRaises(
            ValueError, self.project.include_file, "    \n", "spam")

    def test_should_raise_exception_when_filename_is_empty_string(self):
        self.assertRaises(
            ValueError, self.project.include_file, "eggs", "\t    \n")

    def test_should_raise_exception_when_package_path_not_given(self):
        self.assertRaises(ValueError, self.project.include_directory, None, "spam")

    def test_should_raise_exception_when_package_path_is_empty_string(self):
        self.assertRaises(ValueError, self.project.include_directory, "\t  \n", "spam")

    def test_should_raise_exception_when_patterns_list_not_given(self):
        self.assertRaises(ValueError, self.project.include_directory, "spam", None)

    def test_should_raise_exception_when_patterns_list_is_empty_list(self):
        self.assertRaises(ValueError, self.project.include_directory, "spam", ["\t   \n"])

    def test_should_package_data_dictionary_is_empty(self):
        self.assertEquals({}, self.project.package_data)

    def test_should_add_filename_to_list_of_included_files_for_package_spam(self):
        self.project.include_file("spam", "eggs")

        self.assertEquals({"spam": ["eggs"]}, self.project.package_data)

    def test_should_add_two_filenames_to_list_of_included_files_for_package_spam(self):
        self.project.include_file("spam", "eggs")
        self.project.include_file("spam", "ham")

        self.assertEquals({"spam": ["eggs", "ham"]}, self.project.package_data)

    def test_should_add_two_filenames_to_list_of_included_files_for_two_different_packages(self):
        self.project.include_file("spam", "eggs")
        self.project.include_file("monty", "ham")

        self.assertEquals(
            {"monty": ["ham"], "spam": ["eggs"]}, self.project.package_data)

    def test_should_add_two_filenames_to_list_of_included_files_and_to_manifest(self):
        self.project.include_file("spam", "eggs")
        self.project.include_file("monty", "ham")

        self.assertEquals(
            {"monty": ["ham"], "spam": ["eggs"]}, self.project.package_data)
        self.assertEquals(
            ["spam/eggs", "monty/ham"], self.project.manifest_included_files)
开发者ID:0xD3ADB33F,项目名称:pybuilder,代码行数:60,代码来源:core_tests.py


示例4: test_should_break_build_when_warnings_and_set

    def test_should_break_build_when_warnings_and_set(self, execute_tool, warnings):
        project = Project(".")
        init_pylint(project)
        project.set_property("pylint_break_build", True)

        with self.assertRaises(BuildFailedException):
            execute_pylint(project, Mock(Logger))
开发者ID:pybuilder,项目名称:pybuilder,代码行数:7,代码来源:pylint_plugin_tests.py


示例5: PythonPathTests

class PythonPathTests(TestCase):

    def setUp(self):
        self.project = Project('/path/to/project')
        self.project.set_property('dir_source_unittest_python', 'unittest')
        self.project.set_property('dir_source_main_python', 'src')

    def test_should_register_source_paths(self):
        system_path = ['some/python/path']

        _register_test_and_source_path_and_return_test_dir(self.project, system_path)

        self.assertTrue('/path/to/project/unittest' in system_path)
        self.assertTrue('/path/to/project/src' in system_path)

    def test_should_put_project_sources_before_other_sources(self):
        system_path = ['irrelevant/sources']

        _register_test_and_source_path_and_return_test_dir(self.project, system_path)

        test_sources_index_in_path = system_path.index('/path/to/project/unittest')
        main_sources_index_in_path = system_path.index('/path/to/project/src')
        irrelevant_sources_index_in_path = system_path.index('irrelevant/sources')
        self.assertTrue(test_sources_index_in_path < irrelevant_sources_index_in_path and
                        main_sources_index_in_path < irrelevant_sources_index_in_path)
开发者ID:010110101001,项目名称:pybuilder,代码行数:25,代码来源:unittest_plugin_tests.py


示例6: test_initialize_sets_variables_correctly

 def test_initialize_sets_variables_correctly(self):
     project = Project(".")
     initialize_plugin(project)
     self.assertEqual(project.get_property("lambda_file_access_control"), "bucket-owner-full-control")
     self.assertEqual(project.get_property("bucket_prefix"), "")
     self.assertEqual(project.get_property("template_file_access_control"), "bucket-owner-full-control")
     self.assertEqual(project.get_property("template_key_prefix"), "")
开发者ID:ImmobilienScout24,项目名称:pybuilder_aws_plugin,代码行数:7,代码来源:pybuilder_aws_plugin_tests.py


示例7: SonarCommandBuilderTests

class SonarCommandBuilderTests(TestCase):

    def setUp(self):
        self.project = Project("any-project")
        self.project.set_property("any-property-name", "any-property-value")
        self.sonar_builder = SonarCommandBuilder("sonar", self.project)

    def test_should_set_sonar_key_to_specific_value(self):
        self.sonar_builder.set_sonar_key("anySonarKey").to("anyValue")

        self.assertEqual(
            self.sonar_builder.as_string,
            "sonar -DanySonarKey=anyValue")

    def test_should_set_sonar_key_to_two_specific_values(self):
        self.sonar_builder.set_sonar_key("anySonarKey").to("anyValue").set_sonar_key("other").to("otherValue")

        self.assertEqual(
            self.sonar_builder.as_string,
            "sonar -DanySonarKey=anyValue -Dother=otherValue")

    def test_should_set_sonar_key_to_property_value(self):
        self.sonar_builder.set_sonar_key("anySonarKey").to_property_value("any-property-name")

        self.assertEqual(self.sonar_builder.as_string, "sonar -DanySonarKey=any-property-value")
开发者ID:0xD3ADB33F,项目名称:pybuilder,代码行数:25,代码来源:sonarqube_plugin_tests.py


示例8: PythonPathTests

class PythonPathTests(TestCase):
    def setUp(self):
        self.project = Project("/path/to/project")
        self.project.set_property("dir_source_unittest_python", "unittest")
        self.project.set_property("dir_source_main_python", "src")

    def test_should_register_source_paths(self):
        system_path = ["some/python/path"]

        _register_test_and_source_path_and_return_test_dir(self.project, system_path)

        self.assertTrue("/path/to/project/unittest" in system_path)
        self.assertTrue("/path/to/project/src" in system_path)

    def test_should_put_project_sources_before_other_sources(self):
        system_path = ["irrelevant/sources"]

        _register_test_and_source_path_and_return_test_dir(self.project, system_path)

        test_sources_index_in_path = system_path.index("/path/to/project/unittest")
        main_sources_index_in_path = system_path.index("/path/to/project/src")
        irrelevant_sources_index_in_path = system_path.index("irrelevant/sources")
        self.assertTrue(
            test_sources_index_in_path < irrelevant_sources_index_in_path
            and main_sources_index_in_path < irrelevant_sources_index_in_path
        )
开发者ID:shakamunyi,项目名称:pybuilder,代码行数:26,代码来源:unittest_plugin_tests.py


示例9: InstallBuildDependenciesTest

class InstallBuildDependenciesTest(unittest.TestCase):

    def setUp(self):
        self.project = Project("unittest", ".")
        self.project.set_property("dir_install_logs", "any_directory")
        self.logger = mock(Logger)
        when(
            pybuilder.plugins.python.install_dependencies_plugin).execute_command(any_value(), any_value(),
                                                                                  shell=True).thenReturn(0)

    def tearDown(self):
        unstub()

    def test_should_install_multiple_dependencies(self):
        self.project.build_depends_on("spam")
        self.project.build_depends_on("eggs")

        install_build_dependencies(self.logger, self.project)

        verify(
            pybuilder.plugins.python.install_dependencies_plugin).execute_command("pip install 'spam'",
                                                                                  any_value(), shell=True)
        verify(
            pybuilder.plugins.python.install_dependencies_plugin).execute_command("pip install 'eggs'",
                                                                                  any_value(), shell=True)
开发者ID:geraldoandradee,项目名称:pybuilder,代码行数:25,代码来源:install_dependencies_plugin_tests.py


示例10: test_should_run_pylint_with_custom_options

    def test_should_run_pylint_with_custom_options(self, execute_tool):
        project = Project(".")
        init_pylint(project)
        project.set_property("pylint_options", ["--test", "-f", "--x=y"])

        execute_pylint(project, Mock(Logger))

        execute_tool.assert_called_with(project, "pylint", ["pylint", "--test", "-f", "--x=y"], True)
开发者ID:Ferreiros-lab,项目名称:pybuilder,代码行数:8,代码来源:pylint_plugin_tests.py


示例11: test_should_delegate_to_project_get_property_when_attribute_is_not_defined

    def test_should_delegate_to_project_get_property_when_attribute_is_not_defined(self):
        project_mock = Project(".")
        project_mock.has_property = Mock(return_value=True)
        project_mock.get_property = Mock(return_value="eggs")

        self.assertEquals("eggs", ProjectDictWrapper(project_mock, Mock())["spam"])

        project_mock.get_property.assert_called_with("spam")
开发者ID:0xD3ADB33F,项目名称:pybuilder,代码行数:8,代码来源:filter_resources_plugin_tests.py


示例12: test_find_files

 def test_find_files(self, discover_mock):
     project = Project('.')
     project.set_property('dir_source_cmdlinetest', '/any/dir')
     project.set_property('cram_test_file_glob', '*.t')
     expected = ['/any/dir/test.cram']
     discover_mock.return_value = expected
     received = _find_files(project)
     self.assertEquals(expected, received)
     discover_mock.assert_called_once_with('/any/dir', '*.t')
开发者ID:0xD3ADB33F,项目名称:pybuilder,代码行数:9,代码来源:cram_plugin_tests.py


示例13: test_running_plugin_failure_no_tests

    def test_running_plugin_failure_no_tests(self,
                                             execute_mock,
                                             read_file_mock,
                                             os_mock,
                                             report_mock,
                                             find_files_mock,
                                             command_mock
                                             ):
        project = Project('.')
        project.set_property('verbose', True)
        project.set_property('dir_source_main_python', 'python')
        project.set_property('dir_source_main_scripts', 'scripts')
        project.set_property("cram_fail_if_no_tests", True)
        logger = Mock()

        command_mock.return_value = ['cram']
        find_files_mock.return_value = []
        report_mock.return_value = 'report_file'
        os_mock.copy.return_value = {}
        read_file_mock.return_value = ['test failes for file', '# results']
        execute_mock.return_value = 1

        self.assertRaises(
            BuildFailedException, run_cram_tests, project, logger)

        execute_mock.assert_not_called()
        expected_info_calls = [call('Running Cram command line tests'),
                               ]
        self.assertEquals(expected_info_calls, logger.info.call_args_list)
开发者ID:0xD3ADB33F,项目名称:pybuilder,代码行数:29,代码来源:cram_plugin_tests.py


示例14: test_running_plugin_cram_from_target

    def test_running_plugin_cram_from_target(self,
                                             execute_mock,
                                             read_file_mock,
                                             os_mock,
                                             report_mock,
                                             find_files_mock,
                                             command_mock
                                             ):
        project = Project('.')
        project.set_property('cram_run_test_from_target', True)
        project.set_property('dir_dist', 'python')
        project.set_property('dir_dist_scripts', 'scripts')
        project.set_property('verbose', False)
        logger = Mock()

        command_mock.return_value = ['cram']
        find_files_mock.return_value = ['test1.cram', 'test2.cram']
        report_mock.return_value = 'report_file'
        os_mock.copy.return_value = {}
        read_file_mock.return_value = ['test failes for file', '# results']
        execute_mock.return_value = 0

        run_cram_tests(project, logger)
        execute_mock.assert_called_once_with(
            ['cram', 'test1.cram', 'test2.cram'], 'report_file',
            error_file_name='report_file',
            env={'PYTHONPATH': './python:', 'PATH': './python/scripts:'}
        )
        expected_info_calls = [call('Running Cram command line tests'),
                               call('Cram tests were fine'),
                               call('results'),
                               ]
        self.assertEquals(expected_info_calls, logger.info.call_args_list)
开发者ID:0xD3ADB33F,项目名称:pybuilder,代码行数:33,代码来源:cram_plugin_tests.py


示例15: test_should_run_pytddmon

    def test_should_run_pytddmon(self, subprocess):
        subprocess.check_output.side_effect = lambda *args, **kwargs: ' '.join(a for a in args)
        project = Project('/path/to/project', name='pybuilder')
        project.set_property('dir_source_main_python', 'path/to/source')
        project.set_property(
            'dir_source_unittest_python', 'src/unittest/python')

        pytddmon_plugin.pytddmon(project, Mock())

        subprocess.Popen.assert_called_with(
            ['which python', 'which pytddmon.py', '--no-pulse'], shell=False, cwd='src/unittest/python', env=ANY)
开发者ID:AnudeepHemachandra,项目名称:pybuilder,代码行数:11,代码来源:pytddmon_plugin_tests.py


示例16: test_initialize_sets_variables_correctly

 def test_initialize_sets_variables_correctly(self):
     project = Project('.')
     initialize_plugin(project)
     self.assertEqual(project.get_property('lambda_file_access_control'),
                      'bucket-owner-full-control')
     self.assertEqual(project.get_property('bucket_prefix'),
                      '')
     self.assertEqual(project.get_property('template_file_access_control'),
                      'bucket-owner-full-control')
     self.assertEqual(project.get_property('template_key_prefix'),
                      '')
开发者ID:codesplicer,项目名称:pybuilder_aws_plugin,代码行数:11,代码来源:pybuilder_aws_plugin_tests.py


示例17: test_should_warn_when_substitution_is_skipped

    def test_should_warn_when_substitution_is_skipped(self):
        project_mock = Project(".")
        logger_mock = Mock()
        project_mock.has_property = Mock(return_value=False)
        project_mock.get_property = Mock()

        self.assertEquals("${n/a}", ProjectDictWrapper(project_mock, logger_mock)["n/a"])

        project_mock.get_property.assert_not_called()
        logger_mock.warn.assert_called_with(
            "Skipping impossible substitution for 'n/a' - there is no matching project attribute or property.")
开发者ID:0xD3ADB33F,项目名称:pybuilder,代码行数:11,代码来源:filter_resources_plugin_tests.py


示例18: test_should_override_current_environment_keys_with_additional_environment

    def test_should_override_current_environment_keys_with_additional_environment(self):
        project = Project('any-directory')
        project.set_property(
            'integrationtest_additional_environment', {'foo': 'mooh'})
        environment = {'foo': 'bar'}

        add_additional_environment_keys(environment, project)

        self.assertEqual(environment,
                         {
                             'foo': 'mooh'
                         })
开发者ID:markmevans,项目名称:pybuilder,代码行数:12,代码来源:integrationtest_plugin_tests.py


示例19: test_ensure_project_properties_are_logged_when_calling_log_project_properties

    def test_ensure_project_properties_are_logged_when_calling_log_project_properties(self):
        project = Project("spam")
        project.set_property("spam", "spam")
        project.set_property("eggs", "eggs")

        self.reactor.project = project
        self.reactor.log_project_properties()

        call_args = self.logger.debug.call_args
        self.assertEquals(call_args[0][0], "Project properties: %s")
        self.assertTrue("basedir : spam" in call_args[0][1])
        self.assertTrue("eggs : eggs" in call_args[0][1])
        self.assertTrue("spam : spam" in call_args[0][1])
开发者ID:wenlien,项目名称:pybuilder,代码行数:13,代码来源:reactor_tests.py


示例20: test_should_merge_additional_environment_into_current_one

    def test_should_merge_additional_environment_into_current_one(self):
        project = Project('any-directory')
        project.set_property(
            'integrationtest_additional_environment', {'foo': 'bar'})
        environment = {'bar': 'baz'}

        add_additional_environment_keys(environment, project)

        self.assertEqual(environment,
                         {
                             'foo': 'bar',
                             'bar': 'baz'
                         })
开发者ID:markmevans,项目名称:pybuilder,代码行数:13,代码来源:integrationtest_plugin_tests.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python distutils_plugin.build_dependency_links_string函数代码示例发布时间:2022-05-25
下一篇:
Python core.use_plugin函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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