本文整理汇总了Python中mockito.any_value函数的典型用法代码示例。如果您正苦于以下问题:Python any_value函数的具体用法?Python any_value怎么用?Python any_value使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了any_value函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_should_return_empty_list_when_no_packages_in_repository
def test_should_return_empty_list_when_no_packages_in_repository(self):
when(RepoContentService).list_architectures(any_value()).thenReturn([])
actual_packages = self.service.list_packages("testrepo")
self.assertEqual([], actual_packages)
verify(RepoContentService).list_architectures(any_value())
开发者ID:fsperling,项目名称:yum-repo-server,代码行数:7,代码来源:testRepoContentService.py
示例2: test_should_return_value_of_check
def test_should_return_value_of_check(self):
when(self.git_client).check_if_is_executable(any_value(), any_value()).thenReturn('value from check')
actual_return_value = self.git_client.is_executable()
self.assertEqual('value from check', actual_return_value)
verify(self.git_client).check_if_is_executable('git', '--version')
开发者ID:jcanfield,项目名称:committer,代码行数:7,代码来源:git_tests.py
示例3: test_should_return_empty_dictionary_when_repository_is_empty_but_directory_contains_file
def test_should_return_empty_dictionary_when_repository_is_empty_but_directory_contains_file(self):
repository_path="/path/to/repository"
repository = "testrepo"
architecture1 = "arch1"
architecture2 = "arch2"
architecture3 = "arch3"
tags_file = "tags.txt"
when(RepoConfigService).getStaticRepoDir(any_value()).thenReturn(repository_path)
when(yum_repo_server.api.services.repoContentService.os).listdir(any_value()).thenReturn([architecture1, architecture2, architecture3, tags_file]).thenReturn([])
when(yum_repo_server.api.services.repoContentService.os.path).isdir(os.path.join(repository_path, architecture1)).thenReturn(True)
when(yum_repo_server.api.services.repoContentService.os.path).isdir(os.path.join(repository_path, architecture2)).thenReturn(True)
when(yum_repo_server.api.services.repoContentService.os.path).isdir(os.path.join(repository_path, architecture3)).thenReturn(True)
when(yum_repo_server.api.services.repoContentService.os.path).isdir(tags_file).thenReturn(False)
actual_architectures = self.service.list_architectures(repository)
self.assertEqual([], actual_architectures)
verify(RepoConfigService).getStaticRepoDir(repository)
verify(yum_repo_server.api.services.repoContentService.os).listdir(repository_path)
verify(yum_repo_server.api.services.repoContentService.os).listdir(os.path.join(repository_path, architecture1))
verify(yum_repo_server.api.services.repoContentService.os).listdir(os.path.join(repository_path, architecture2))
verify(yum_repo_server.api.services.repoContentService.os).listdir(os.path.join(repository_path, architecture3))
verify(yum_repo_server.api.services.repoContentService.os.path).isdir(os.path.join(repository_path, architecture1))
verify(yum_repo_server.api.services.repoContentService.os.path).isdir(os.path.join(repository_path, architecture2))
verify(yum_repo_server.api.services.repoContentService.os.path).isdir(os.path.join(repository_path, architecture3))
verify(yum_repo_server.api.services.repoContentService.os.path).isdir(os.path.join(repository_path, tags_file))
verify(yum_repo_server.api.services.repoContentService.os, never).listdir(os.path.join(repository_path, tags_file))
开发者ID:fsperling,项目名称:yum-repo-server,代码行数:29,代码来源:testRepoContentService.py
示例4: test_run_should_exit_with_error_when_non_existing_file_is_given
def test_run_should_exit_with_error_when_non_existing_file_is_given(self):
mock_when(yadt_lint)._get_configuration(any_value()).thenRaise(IOError)
mock_when(yadt_lint.sys).exit(any_value()).thenReturn(None)
yadt_lint._validate_yaml_input(IOError)
verify(yadt_lint.sys).exit(1)
开发者ID:yadt,项目名称:yadtlint,代码行数:7,代码来源:yadtlint_tests.py
示例5: test_should_return_empty_dictionary_even_if_meta_data_has_been_generated
def test_should_return_empty_dictionary_even_if_meta_data_has_been_generated(self):
repository_path="/path/to/repository"
repository = "testrepo"
architecture1 = "arch1"
architecture2 = "arch2"
repodata_directory = "repodata"
metadata_xml_file = "repomd.xml"
when(RepoConfigService).getStaticRepoDir(any_value()).thenReturn(repository_path)
when(yum_repo_server.api.services.repoContentService.os).listdir(any_value()).thenReturn([architecture1, architecture2, repodata_directory, metadata_xml_file]).thenReturn([])
when(yum_repo_server.api.services.repoContentService.os.path).isdir(os.path.join(repository_path, architecture1)).thenReturn(True)
when(yum_repo_server.api.services.repoContentService.os.path).isdir(os.path.join(repository_path, architecture2)).thenReturn(True)
when(yum_repo_server.api.services.repoContentService.os.path).isdir(os.path.join(repository_path, repodata_directory)).thenReturn(True)
actual_architectures = self.service.list_architectures(repository)
self.assertEqual([], actual_architectures)
verify(RepoConfigService).getStaticRepoDir(repository)
verify(yum_repo_server.api.services.repoContentService.os).listdir(repository_path)
verify(yum_repo_server.api.services.repoContentService.os).listdir(os.path.join(repository_path, architecture1))
verify(yum_repo_server.api.services.repoContentService.os).listdir(os.path.join(repository_path, architecture2))
verify(yum_repo_server.api.services.repoContentService.os.path).isdir(os.path.join(repository_path, architecture1))
verify(yum_repo_server.api.services.repoContentService.os.path).isdir(os.path.join(repository_path, architecture2))
verify(yum_repo_server.api.services.repoContentService.os.path, never).isdir(os.path.join(repository_path, repodata_directory))
开发者ID:fsperling,项目名称:yum-repo-server,代码行数:25,代码来源:testRepoContentService.py
示例6: test_should_create_destination_directories_when_propagating_repository
def test_should_create_destination_directories_when_propagating_repository(self):
destination_repository_path = "destination-static-repository-path"
destination_repository = "destination-repo"
destination_path1 = os.path.join(destination_repository_path, "arch1")
destination_path2 = os.path.join(destination_repository_path, "arch2")
package_path1 = os.path.join("source-repository-path", "arch1", "spam.rpm")
package_path2 = os.path.join("source-repository-path", "arch2", "egg.rpm")
when(RepoConfigService).determine_static_repository_path(destination_repository).thenReturn(destination_repository_path)
when(RepoContentService).list_packages(any_value()).thenReturn([package_path1, package_path2])
when(yum_repo_server.api.services.repoPropagationService.shutil).move(any_value(), any_value()).thenReturn(None)
when(yum_repo_server.api.services.repoPropagationService.os.path).exists(any_value()).thenReturn(False)
when(yum_repo_server.api.services.repoPropagationService.os).makedirs(any_value()).thenReturn(None)
self.service.propagate_repository("source-repo", destination_repository)
verify(RepoConfigService).determine_static_repository_path(destination_repository)
verify(RepoContentService).list_packages("source-repo")
verify(yum_repo_server.api.services.repoPropagationService.os.path).exists(destination_path1)
verify(yum_repo_server.api.services.repoPropagationService.os).makedirs(destination_path1)
verify(yum_repo_server.api.services.repoPropagationService.shutil).move(package_path1, destination_path1)
verify(yum_repo_server.api.services.repoPropagationService.os.path).exists(destination_path2)
verify(yum_repo_server.api.services.repoPropagationService.os).makedirs(destination_path2)
verify(yum_repo_server.api.services.repoPropagationService.shutil).move(package_path2, destination_path2)
开发者ID:grom-it,项目名称:yum-repo-server,代码行数:27,代码来源:testRepoPropagationService.py
示例7: setUp
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)
开发者ID:krishmatreja,项目名称:pybuilder,代码行数:7,代码来源:install_dependencies_plugin_tests.py
示例8: test_should_install_requirements_file_dependency
def test_should_install_requirements_file_dependency(self):
dependency = RequirementsFile("requirements.txt")
install_dependency(self.logger, self.project, dependency)
verify(pybuilder.plugins.python.install_dependencies_plugin).execute_command(
[PIP_EXECUTABLE, "install", '-r', "requirements.txt"], any_value(), env=any_value(), shell=False)
开发者ID:xbhuang,项目名称:pybuilder,代码行数:7,代码来源:install_dependencies_plugin_tests.py
示例9: test_should_propagate_package_using_rpm_service
def test_should_propagate_package_using_rpm_service(self):
package_name = "package_name"
architecture = "architecture"
source_repository_name = "source-repository-name"
source_path = "source-static-repository-path"
destination_repository_name = "destination-repository-name"
destination_path = "destination-static-repository-path"
when(RepoConfigService).determine_static_repository_path(source_repository_name).thenReturn(source_path)
when(RepoConfigService).determine_static_repository_path(destination_repository_name).thenReturn(destination_path)
when(yum_repo_server.api.services.repoPropagationService.os.path).exists(any_value()).thenReturn(True)
when(yum_repo_server.api.services.repoPropagationService).create_rpm_file_object(any_value()).thenReturn(True)
when(yum_repo_server.api.services.repoPropagationService.shutil).move(any_value(), any_value()).thenReturn(None)
actual_file_name = self.service.propagatePackage(package_name, source_repository_name, destination_repository_name, architecture)
self.assertEqual(package_name, actual_file_name)
verify(RepoConfigService).determine_static_repository_path(source_repository_name)
verify(RepoConfigService).determine_static_repository_path(destination_repository_name)
verify(yum_repo_server.api.services.repoPropagationService).create_rpm_file_object(package_name)
source_rpm_path = os.path.join(source_path, architecture, package_name)
destination_rpm_parent_dir = os.path.join(destination_path, architecture)
destination_rpm_path = os.path.join(destination_rpm_parent_dir, package_name)
verify(yum_repo_server.api.services.repoPropagationService.os.path).exists(source_rpm_path)
verify(yum_repo_server.api.services.repoPropagationService.os.path).exists(destination_rpm_parent_dir)
verify(yum_repo_server.api.services.repoPropagationService.shutil).move(source_rpm_path, destination_rpm_path)
开发者ID:grom-it,项目名称:yum-repo-server,代码行数:33,代码来源:testRepoPropagationService.py
示例10: test_should_install_dependency_without_version
def test_should_install_dependency_without_version(self):
dependency = Dependency("spam")
install_dependency(self.logger, self.project, dependency)
verify(pybuilder.plugins.python.install_dependencies_plugin).execute_command(
[PIP_EXECUTABLE, "install", 'spam'], any_value(), env=any_value(), shell=False)
开发者ID:xbhuang,项目名称:pybuilder,代码行数:7,代码来源:install_dependencies_plugin_tests.py
示例11: test_should_install_dependency_with_version_and_operator
def test_should_install_dependency_with_version_and_operator(self):
dependency = Dependency("spam", "==0.1.2")
install_dependency(self.logger, self.project, dependency)
verify(pybuilder.plugins.python.install_dependencies_plugin).execute_command(
PIP_EXEC_STANZA + ["install", 'spam==0.1.2'], any_value(), env=any_value(), shell=False)
开发者ID:RonaldChristopher,项目名称:pybuilder,代码行数:7,代码来源:install_dependencies_plugin_tests.py
示例12: ensure_that_get_package_content_checks_if_package_is_hosted
def ensure_that_get_package_content_checks_if_package_is_hosted():
pypiproxy.services._hosted_packages_index = mock()
when(pypiproxy.services._hosted_packages_index).contains(any_value(), any_value()).thenReturn(True)
pypiproxy.services.get_package_content("spam", "0.1.1")
verify(pypiproxy.services._hosted_packages_index).contains("spam", "0.1.1")
开发者ID:andante-project,项目名称:pypiproxy,代码行数:7,代码来源:services_pyfix_tests.py
示例13: test_should_install_dependency_without_version_on_windows_derivate
def test_should_install_dependency_without_version_on_windows_derivate(self):
dependency = Dependency("spam")
install_dependency(self.logger, self.project, dependency)
verify(pybuilder.plugins.python.install_dependencies_plugin).execute_command(
PIP_EXEC_STANZA + ["install", "spam"], any_value(), env=any_value(), shell=False)
开发者ID:RonaldChristopher,项目名称:pybuilder,代码行数:7,代码来源:install_dependencies_plugin_tests.py
示例14: test_should_prepend_hg_to_given_arguments
def test_should_prepend_hg_to_given_arguments (self):
when(self.mercurial_client)._hg(any_value(), any_value(), any_value()).thenReturn(None)
when(self.mercurial_client)._hg(any_value()).thenReturn(None)
self.mercurial_client.commit('This is a commit message.')
verify(self.mercurial_client)._hg('commit', '-m', 'This is a commit message.')
verify(self.mercurial_client)._hg('push')
开发者ID:jcanfield,项目名称:committer,代码行数:8,代码来源:mercurial_tests.py
示例15: test_should_perform_command_and_receive_ok
def test_should_perform_command_and_receive_ok(self):
mock_socket = mock()
when(livestatus_service.livestatus.time).time().thenReturn(123)
when(livestatus_service.livestatus.socket).socket(any_value(), any_value()).thenReturn(mock_socket)
perform_command('foobar', '/path/to/socket')
verify(mock_socket).send(b'COMMAND [123] foobar\n')
开发者ID:tklein,项目名称:livestatus_service,代码行数:8,代码来源:livestatus_tests.py
示例16: test_should_upgrade_dependencies
def test_should_upgrade_dependencies(self):
self.project.set_property("install_dependencies_upgrade", True)
dependency = Dependency("spam")
install_dependency(self.logger, self.project, dependency)
verify(pybuilder.plugins.python.install_dependencies_plugin).execute_command(
PIP_EXEC_STANZA + ["install", "--upgrade", 'spam'], any_value(), env=any_value(), shell=False)
开发者ID:RonaldChristopher,项目名称:pybuilder,代码行数:8,代码来源:install_dependencies_plugin_tests.py
示例17: test_should_not_use_extra_index_url_when_index_url_is_not_set
def test_should_not_use_extra_index_url_when_index_url_is_not_set(self):
self.project.set_property("install_dependencies_extra_index_url", "some_index_url")
dependency = Dependency("spam")
install_dependency(self.logger, self.project, dependency)
verify(pybuilder.plugins.python.install_dependencies_plugin).execute_command(
PIP_EXEC_STANZA + ["install", 'spam'], any_value(), env=any_value(), shell=False)
开发者ID:Ferreiros-lab,项目名称:pybuilder,代码行数:8,代码来源:install_dependencies_plugin_tests.py
示例18: should_send_not_found_when_trying_to_get_package_content_for_nonexisting_package
def should_send_not_found_when_trying_to_get_package_content_for_nonexisting_package(web_application):
when(webapp).get_package_content(any_value(), any_value()).thenReturn(None)
response = web_application.get("/package/package_name/version/package_name-version.tar.gz")
assert_that(response.status_code).is_equal_to(404)
verify(webapp).get_package_content("package_name", "version")
开发者ID:andante-project,项目名称:pypiproxy,代码行数:8,代码来源:webapp_pyfix_tests.py
示例19: test_should_raise_exception_when_repository_directory_does_not_exist
def test_should_raise_exception_when_repository_directory_does_not_exist(self):
service = RepoConfigService()
when(service).getStaticRepoDir(any_value()).thenReturn("path/to/repository")
when(yum_repo_server.api.services.repoConfigService.os.path).exists(any_value()).thenReturn(False)
self.assertRaises(Exception, service.determine_static_repository_path, ())
unstub()
开发者ID:grom-it,项目名称:yum-repo-server,代码行数:9,代码来源:testRepoConfigService.py
示例20: test_should_not_use_insecure_flags_when_pip_version_is_too_low
def test_should_not_use_insecure_flags_when_pip_version_is_too_low(self):
dependency = Dependency("spam")
self.project.set_property("install_dependencies_insecure_installation", ["spam"])
when(pybuilder.pip_utils)._pip_disallows_insecure_packages_by_default().thenReturn(False)
install_dependency(self.logger, self.project, dependency)
verify(pybuilder.plugins.python.install_dependencies_plugin).execute_command(
PIP_EXEC_STANZA + ["install", 'spam'], any_value(), env=any_value(), shell=False)
开发者ID:RonaldChristopher,项目名称:pybuilder,代码行数:9,代码来源:install_dependencies_plugin_tests.py
注:本文中的mockito.any_value函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论