def create_project(): project = Project("/") project.build_depends_on("testingframework") project.depends_on("sometool") project.depends_on( "pyassert", url= "https://github.com/downloads/halimath/pyassert/pyassert-0.2.2.tar.gz") project.name = "Spam and Eggs" project.version = "1.2.3" project.summary = "This is a simple integration-test for distutils plugin." project.description = "As you might have guessed we have nothing to say here." project.authors = [ Author("Udo Juettner", "*****@*****.**"), Author("Michael Gruber", "*****@*****.**") ] project.license = "WTFPL" project.url = "http://github.com/pybuilder/pybuilder" project.explicit_namespaces = ["foo.bar", "quick.brown.fox"] def return_dummy_list(): return ["spam", "eggs"] project.list_scripts = return_dummy_list project.list_packages = return_dummy_list project.list_modules = return_dummy_list project.set_property( "distutils_classifiers", ["Development Status :: 5 - Beta", "Environment :: Console"]) project.install_file("dir", "file1") project.install_file("dir", "file2") project.include_file("spam", "eggs") return project
def create_project(): project = Project("/") project.build_depends_on("testingframework") project.depends_on("sometool") project.depends_on( "pyassert", url="https://github.com/downloads/halimath/pyassert/pyassert-0.2.2.tar.gz") project.name = "Spam and Eggs" project.version = "1.2.3" project.summary = "This is a simple integration-test for distutils plugin." project.description = "As you might have guessed we have nothing to say here." project.authors = [ Author("Udo Juettner", "*****@*****.**"), Author("Michael Gruber", "*****@*****.**")] project.license = "WTFPL" project.url = "http://github.com/pybuilder/pybuilder" def return_dummy_list(): return ["spam", "eggs"] project.list_scripts = return_dummy_list project.list_packages = return_dummy_list project.list_modules = return_dummy_list project.set_property("distutils_classifiers", [ "Development Status :: 5 - Beta", "Environment :: Console"]) project.install_file("dir", "file1") project.install_file("dir", "file2") project.include_file("spam", "eggs") return project
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") self.project.build_depends_on_requirements("requirements-dev.txt") 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) verify(pybuilder.plugins.python.install_dependencies_plugin ).execute_command("pip install '-rrequirements-dev.txt'", any_value(), shell=True)
class InstallDependenciesTest(unittest.TestCase): def setUp(self): self.project = Project("unittest", ".") self.project.set_property("dir_install_logs", "any_directory") self.logger = mock(Logger) initialize_install_dependencies_plugin(self.project) when(pybuilder.plugins.python.install_dependencies_plugin ).execute_command(any_value(), any_value(), env=any_value(), shell=False).thenReturn(0) def tearDown(self): unstub() def test_should_install_single_dependency_without_version(self): self.project.depends_on("spam") self.project.build_depends_on("eggs") install_dependencies(self.logger, self.project) verify(pybuilder.plugins.python.install_dependencies_plugin ).execute_command([PIP_EXECUTABLE, "install", 'spam'], any_value(), shell=False) verify(pybuilder.plugins.python.install_dependencies_plugin ).execute_command([PIP_EXECUTABLE, "install", 'eggs'], any_value(), shell=False)
class InstallBuildDependenciesTest(unittest.TestCase): def setUp(self): self.project = Project("unittest", ".") self.project.set_property("dir_install_logs", "any_directory") self.logger = mock(Logger) initialize_install_dependencies_plugin(self.project) when(pybuilder.plugins.python.install_dependencies_plugin).execute_command(any_value(), any_value(), env=any_value(), shell=False).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") self.project.build_depends_on_requirements("requirements-dev.txt") install_build_dependencies(self.logger, self.project) verify(pybuilder.plugins.python.install_dependencies_plugin).execute_command( PIP_EXEC_STANZA + ["install", "spam"], any_value(), shell=False) verify(pybuilder.plugins.python.install_dependencies_plugin).execute_command( PIP_EXEC_STANZA + ["install", "eggs"], any_value(), shell=False) verify(pybuilder.plugins.python.install_dependencies_plugin).execute_command( PIP_EXEC_STANZA + ["install", '-r', 'requirements-dev.txt'], any_value(), shell=False)
class InstallBuildDependenciesTest(unittest.TestCase): def setUp(self): self.project = Project("unittest", ".") self.project.set_property("dir_install_logs", "any_directory") self.logger = mock(Logger) initialize_install_dependencies_plugin(self.project) when(pybuilder.plugins.python.install_dependencies_plugin ).execute_command(any_value(), any_value(), env=any_value(), shell=False).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") self.project.build_depends_on_requirements("requirements-dev.txt") install_build_dependencies(self.logger, self.project) verify(pybuilder.plugins.python.install_dependencies_plugin ).execute_command(PIP_EXEC_STANZA + ["install", "spam"], any_value(), shell=False) verify(pybuilder.plugins.python.install_dependencies_plugin ).execute_command(PIP_EXEC_STANZA + ["install", "eggs"], any_value(), shell=False) verify(pybuilder.plugins.python.install_dependencies_plugin ).execute_command(PIP_EXEC_STANZA + ["install", '-r', 'requirements-dev.txt'], any_value(), shell=False)
class InstallDependenciesTest(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_single_dependency_without_version(self): self.project.depends_on("spam") self.project.build_depends_on("eggs") install_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)
class InstallBuildDependenciesTest(unittest.TestCase): def setUp(self): self.project = Project("unittest", ".") self.project.set_property("dir_install_logs", "any_directory") self.project.set_property("dir_target", "/any_target_directory") self.logger = Mock(Logger) initialize_install_dependencies_plugin(self.project) @patch("pybuilder.pip_utils.create_constraint_file") @patch("pybuilder.pip_utils.get_package_version", return_value={}) @patch("pybuilder.pip_utils.execute_command", return_value=0) def test_should_install_multiple_dependencies(self, exec_command, get_package_version, constraint_file): self.project.build_depends_on("spam") self.project.build_depends_on("eggs") self.project.build_depends_on_requirements("requirements-dev.txt") install_build_dependencies(self.logger, self.project) exec_command(PIP_EXEC_STANZA + ["install", "spam"], ANY, shell=False) exec_command(PIP_EXEC_STANZA + ["install", "eggs"], ANY, shell=False) exec_command(PIP_EXEC_STANZA + ["install", '-r', 'requirements-dev.txt'], ANY, shell=False)
class InstallDependenciesTest(unittest.TestCase): def setUp(self): self.project = Project("unittest", ".") self.project.set_property("dir_install_logs", "any_directory") self.logger = Mock(Logger) initialize_install_dependencies_plugin(self.project) @patch("pybuilder.plugins.python.install_dependencies_plugin.execute_command", return_value=0) def test_should_install_single_dependency_without_version(self, exec_command, get_package_version): self.project.depends_on("spam") self.project.build_depends_on("eggs") install_dependencies(self.logger, self.project) exec_command(PIP_EXEC_STANZA + ["install", 'spam'], ANY, shell=False) exec_command(PIP_EXEC_STANZA + ["install", 'eggs'], ANY, shell=False)
class InstallBuildDependenciesTest(unittest.TestCase): def setUp(self): self.project = Project("unittest", ".") self.project.set_property("install_env", "whatever") self.project.set_property("dir_install_logs", "any_directory") self.project.set_property("dir_target", "/any_target_directory") self.logger = Mock(Logger) self.reactor = Mock() self.pyb_env = Mock() self.pyb_env.executable = ["a/b"] self.pyb_env.env_dir = "a" self.pyb_env.execute_command.return_value = 0 self.reactor.python_env_registry = {"whatever": self.pyb_env} initialize_install_dependencies_plugin(self.project) @patch("pybuilder.install_utils.tail_log") @patch("pybuilder.install_utils.open") @patch("pybuilder.install_utils.create_constraint_file") @patch("pybuilder.install_utils.get_packages_info", return_value={}) def test_should_install_multiple_dependencies(self, *_): self.project.build_depends_on("spam") self.project.build_depends_on("eggs") self.project.build_depends_on_requirements("requirements-dev.txt") install_build_dependencies(self.logger, self.project, self.reactor) exec_cmd = self.pyb_env.execute_command call_stanza = self.pyb_env.executable + PIP_MODULE_STANZA + [ "install", "-c", ANY ] exec_cmd.assert_called_with( call_stanza + ["eggs", "spam", "-r", "requirements-dev.txt"], outfile_name=ANY, error_file_name=ANY, env=ANY, cwd=None, shell=False, no_path_search=True)
def set_properties(project: Project): # Dependencies project.depends_on("kombu", "4.0.2") project.build_depends_on("sqlalchemy") project.build_depends_on("django") # Cram Configuration project.set_property("cram_fail_if_no_tests", False) # Disable flake8 project.set_property("flake8_break_build", False) # Integration Tests Coverage is disabled since there are no integration tests project.set_property("unittest_coverage_threshold_warn", 0) project.set_property("unittest_coverage_branch_threshold_warn", 0) project.set_property("unittest_coverage_branch_partial_threshold_warn", 0) project.set_property("unittest_coverage_allow_non_imported_modules", True) project.set_property("integrationtest_coverage_threshold_warn", 0) project.set_property("integrationtest_coverage_branch_threshold_warn", 0) project.set_property("integrationtest_coverage_branch_partial_threshold_warn", 0) project.set_property("integrationtest_coverage_allow_non_imported_modules", True) project.set_property("pybuilder_header_plugin_break_build", False) project.set_property("copy_resources_target", "$dir_dist/karellen") project.get_property("copy_resources_glob").append("LICENSE.bsd3") project.get_property("copy_resources_glob").append("LICENSE.apache") project.include_file("karellen", "LICENSE.bsd3") project.include_file("karellen", "LICENSE.apache") # Distutils project.set_property("distutils_classifiers", project.get_property("distutils_classifiers") + [ 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Topic :: Software Development :: Libraries', 'Topic :: Software Development :: Libraries :: Python Modules', 'Topic :: Internet', ]) project.set_property("pdoc_module_name", "karellen.kombu")
def set_properties(project: Project): # Dependencies project.depends_on("gevent") project.build_depends_on("wsaccel") project.build_depends_on("ujson") project.build_depends_on("websocket-client", "~=0.0") project.build_depends_on("gunicorn") # Cram Configuration project.set_property("cram_fail_if_no_tests", False) # Disable flake8 project.set_property("flake8_break_build", False) # Integration Tests Coverage is disabled since there are no integration tests project.set_property("unittest_coverage_threshold_warn", 0) project.set_property("unittest_coverage_branch_threshold_warn", 0) project.set_property("unittest_coverage_branch_partial_threshold_warn", 0) project.set_property("unittest_coverage_allow_non_imported_modules", True) project.set_property("integrationtest_coverage_threshold_warn", 0) project.set_property("integrationtest_coverage_branch_threshold_warn", 0) project.set_property( "integrationtest_coverage_branch_partial_threshold_warn", 0) project.set_property("integrationtest_coverage_allow_non_imported_modules", True) project.set_property("pybuilder_header_plugin_break_build", False) project.set_property("copy_resources_target", "$dir_dist") project.get_property("copy_resources_glob").append("LICENSE") project.get_property("filter_resources_glob").append( "**/geventwebsocket/__init__.py") # Distutils project.set_property( "distutils_classifiers", project.get_property("distutils_classifiers") + [ 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Topic :: Software Development :: Libraries', 'Topic :: Software Development :: Libraries :: Python Modules', 'Topic :: Internet', ]) project.set_property("pdoc_module_name", "geventwebsocket")
class ProjectValidationTest(unittest.TestCase): def setUp(self): self.project = Project(basedir="/imaginary", name="Unittest") def test_should_validate_empty_project(self): validation_messages = self.project.validate() assert_that(validation_messages).is_empty() def test_should_not_validate_project_with_duplicate_dependency_but_different_versions(self): self.project.depends_on('spam', version='1') self.project.depends_on('spam', version='2') validation_messages = self.project.validate() assert_that(validation_messages).contains( "Runtime dependency 'spam' has been defined multiple times.") def test_should_not_validate_project_with_duplicate_dependency_when_version_is_given_for_one(self): self.project.depends_on('spam') self.project.depends_on('spam', version='2') validation_messages = self.project.validate() assert_that(validation_messages).contains( "Runtime dependency 'spam' has been defined multiple times.") def test_should_not_validate_project_with_duplicate_dependency_when_urls_are_different(self): self.project.depends_on('spam', url='y') self.project.depends_on('spam', url='x') validation_messages = self.project.validate() assert_that(validation_messages).contains( "Runtime dependency 'spam' has been defined multiple times.") def test_should_not_validate_project_with_duplicate_dependency_when_url_is_given_for_one(self): self.project.depends_on('spam') self.project.depends_on('spam', url='x') validation_messages = self.project.validate() assert_that(validation_messages).contains( "Runtime dependency 'spam' has been defined multiple times.") def test_should_not_validate_project_with_duplicate_dependency_for_more_than_two_times(self): self.project.depends_on('spam', version='1') self.project.depends_on('spam', version='2') self.project.depends_on('spam', version='3') validation_messages = self.project.validate() assert_that(validation_messages).contains( "Runtime dependency 'spam' has been defined multiple times.") assert_that(len(validation_messages)).equals(1) def test_should_not_validate_project_with_duplicate_build_dependency_but_different_versions(self): self.project.build_depends_on('spam', version='1') self.project.build_depends_on('spam', version='2') validation_messages = self.project.validate() assert_that(validation_messages).contains( "Build dependency 'spam' has been defined multiple times.") def test_should_not_validate_project_with_duplicate_build_dependency_when_version_is_given_for_one(self): self.project.build_depends_on('spam') self.project.build_depends_on('spam', version='2') validation_messages = self.project.validate() assert_that(validation_messages).contains( "Build dependency 'spam' has been defined multiple times.") def test_should_not_validate_project_with_duplicate_build_dependency_when_urls_are_different(self): self.project.build_depends_on('spam', url='y') self.project.build_depends_on('spam', url='x') validation_messages = self.project.validate() assert_that(validation_messages).contains( "Build dependency 'spam' has been defined multiple times.") def test_should_not_validate_project_with_duplicate_build_dependency_when_url_is_given_for_one(self): self.project.build_depends_on('spam') self.project.build_depends_on('spam', url='x') validation_messages = self.project.validate() assert_that(validation_messages).contains( "Build dependency 'spam' has been defined multiple times.") def test_should_not_validate_project_with_duplicate_build_dependency_for_more_than_two_times(self): self.project.build_depends_on('spam', version='1') self.project.build_depends_on('spam', version='2') self.project.build_depends_on('spam', version='3') validation_messages = self.project.validate() assert_that(validation_messages).contains( "Build dependency 'spam' has been defined multiple times.") assert_that(len(validation_messages)).equals(1) def test_should_not_validate_project_with_runtime_dependency_being_also_given_as_build_dependency(self): self.project.depends_on('spam') self.project.build_depends_on('spam') validation_messages = self.project.validate() assert_that(validation_messages).contains( "Runtime dependency 'spam' has also been given as build dependency.") assert_that(len(validation_messages)).equals(1)
class ProjectValidationTest(unittest.TestCase): def setUp(self): self.project = Project(basedir="/imaginary", name="Unittest") def test_should_validate_empty_project(self): validation_messages = self.project.validate() self.assertFalse(validation_messages) def test_should_not_validate_project_with_duplicate_dependency_but_different_versions( self): self.project.depends_on('spam', version='1') self.project.depends_on('spam', version='2') validation_messages = self.project.validate() self.assertTrue( "Runtime dependency 'spam' has been defined multiple times." in validation_messages) def test_should_not_validate_project_with_duplicate_dependency_when_version_is_given_for_one( self): self.project.depends_on('spam') self.project.depends_on('spam', version='2') validation_messages = self.project.validate() self.assertTrue( "Runtime dependency 'spam' has been defined multiple times." in validation_messages) def test_should_not_validate_project_with_duplicate_dependency_when_urls_are_different( self): self.project.depends_on('spam', url='y') self.project.depends_on('spam', url='x') validation_messages = self.project.validate() self.assertTrue( "Runtime dependency 'spam' has been defined multiple times." in validation_messages) def test_should_not_validate_project_with_duplicate_dependency_when_url_is_given_for_one( self): self.project.depends_on('spam') self.project.depends_on('spam', url='x') validation_messages = self.project.validate() self.assertTrue( "Runtime dependency 'spam' has been defined multiple times." in validation_messages) def test_should_not_validate_project_with_duplicate_dependency_for_more_than_two_times( self): self.project.depends_on('spam', version='1') self.project.depends_on('spam', version='2') self.project.depends_on('spam', version='3') validation_messages = self.project.validate() self.assertTrue( "Runtime dependency 'spam' has been defined multiple times." in validation_messages) self.assertEquals(len(validation_messages), 1) def test_should_not_validate_project_with_duplicate_build_dependency_but_different_versions( self): self.project.build_depends_on('spam', version='1') self.project.build_depends_on('spam', version='2') validation_messages = self.project.validate() self.assertTrue( "Build dependency 'spam' has been defined multiple times." in validation_messages) def test_should_not_validate_project_with_duplicate_build_dependency_when_version_is_given_for_one( self): self.project.build_depends_on('spam') self.project.build_depends_on('spam', version='2') validation_messages = self.project.validate() self.assertTrue( "Build dependency 'spam' has been defined multiple times." in validation_messages) def test_should_not_validate_project_with_duplicate_build_dependency_when_urls_are_different( self): self.project.build_depends_on('spam', url='y') self.project.build_depends_on('spam', url='x') validation_messages = self.project.validate() self.assertTrue( "Build dependency 'spam' has been defined multiple times." in validation_messages) def test_should_not_validate_project_with_duplicate_build_dependency_when_url_is_given_for_one( self): self.project.build_depends_on('spam') self.project.build_depends_on('spam', url='x') validation_messages = self.project.validate() self.assertTrue( "Build dependency 'spam' has been defined multiple times." in validation_messages) def test_should_not_validate_project_with_duplicate_build_dependency_for_more_than_two_times( self): self.project.build_depends_on('spam', version='1') self.project.build_depends_on('spam', version='2') self.project.build_depends_on('spam', version='3') validation_messages = self.project.validate() self.assertTrue( "Build dependency 'spam' has been defined multiple times." in validation_messages) self.assertEquals(len(validation_messages), 1) def test_should_not_validate_project_with_runtime_dependency_being_also_given_as_build_dependency( self): self.project.depends_on('spam') self.project.build_depends_on('spam') validation_messages = self.project.validate() self.assertTrue( "Runtime dependency 'spam' has also been given as build dependency." in validation_messages) self.assertEquals(len(validation_messages), 1)