当前位置: 首页>>代码示例>>Python>>正文


Python Mock.version方法代码示例

本文整理汇总了Python中unittest.mock.Mock.version方法的典型用法代码示例。如果您正苦于以下问题:Python Mock.version方法的具体用法?Python Mock.version怎么用?Python Mock.version使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在unittest.mock.Mock的用法示例。


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

示例1: test_dir_from_spec

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import version [as 别名]
 def test_dir_from_spec(self):
     mock = Mock(spec=unittest.TestCase)
     testcase_attrs = set(dir(unittest.TestCase))
     attrs = set(dir(mock))
     self.assertEqual(set(), testcase_attrs - attrs)
     mock.version = 3
     self.assertEqual(dir(mock).count('version'), 1)
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:9,代码来源:testmock.py

示例2: make_mocks

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import version [as 别名]
def make_mocks():
    descriptor = Mock()
    descriptor.version = (4, 0, 0)
    descriptor.mode.transports = TRANSPORT.CCID
    driver = Mock()
    driver.key_type = YUBIKEY.YK4
    driver.mode = Mode.from_code(1)
    driver.read_config.return_value = b'\5\5\3\0\0\0'
    return descriptor, driver
开发者ID:Yubico,项目名称:yubikey-manager,代码行数:11,代码来源:test_device.py

示例3: test_addon_not_found

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import version [as 别名]
    def test_addon_not_found(self):
        class MockVersion:
            @property
            def addon(self):
                raise ObjectDoesNotExist

        file = Mock()
        file.version = MockVersion()
        self.assertRaises(http.Http404, allowed, self.request, file)
开发者ID:diox,项目名称:olympia,代码行数:11,代码来源:test_decorators.py

示例4: test_too_fresh_requirement

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import version [as 别名]
    def test_too_fresh_requirement(self, getDistributionMock):
        requirement = 'package==0.1.2'

        moduleMock = Mock()
        moduleMock.version = '0.1.3'
        getDistributionMock.return_value = moduleMock

        self.assertRaisesRegex(IncorrectPackageVersionError,
                               re.escape("'package 0.1.3' version mismatch (==0.1.2)"), verify_packages, requirement)
开发者ID:automl,项目名称:auto-sklearn,代码行数:11,代码来源:test_dependencies.py

示例5: test_outdated_requirement

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import version [as 别名]
    def test_outdated_requirement(self, getDistributionMock):
        requirement = 'package>=0.1'

        moduleMock = Mock()
        moduleMock.version = '0.0.9'
        getDistributionMock.return_value = moduleMock

        self.assertRaisesRegex(IncorrectPackageVersionError,
                               re.escape("'package 0.0.9' version mismatch (>=0.1)"), verify_packages, requirement)
开发者ID:automl,项目名称:auto-sklearn,代码行数:11,代码来源:test_dependencies.py

示例6: test_dir_from_spec

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import version [as 别名]
    def test_dir_from_spec(self):
        mock = Mock(spec=unittest.TestCase)
        testcase_attrs = set(dir(unittest.TestCase))
        attrs = set(dir(mock))

        # all attributes from the spec are included
        self.assertEqual(set(), testcase_attrs - attrs)

        # shadow a sys attribute
        mock.version = 3
        self.assertEqual(dir(mock).count('version'), 1)
开发者ID:MarkTseng,项目名称:cpython,代码行数:13,代码来源:testmock.py

示例7: test_correct_package_versions

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import version [as 别名]
    def test_correct_package_versions(self, getDistributionMock):
        requirement = 'package==0.1.2\n' \
                      'package>0.1\n' \
                      'package>=0.1'

        moduleMock = Mock()
        moduleMock.version = '0.1.2'
        getDistributionMock.return_value = moduleMock

        verify_packages(requirement)

        getDistributionMock.assert_called_with('package')
        self.assertEqual(3, len(getDistributionMock.call_args_list))
开发者ID:automl,项目名称:auto-sklearn,代码行数:15,代码来源:test_dependencies.py

示例8: Mock

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import version [as 别名]
import os
import sys
import pytest
from unittest.mock import Mock

# mocking sublime
mocked_sublime = Mock()
mocked_sublime.version = Mock(return_value=3001)
sys.modules['sublime'] = mocked_sublime

# adding lib folder to syspath
directory = os.path.dirname(os.path.realpath(__file__))
libs_path = os.path.join(directory, '..', 'codeformatter', 'lib')
if libs_path not in sys.path:
    sys.path.append(libs_path)


@pytest.fixture
def php_view():
    mview = Mock()
    mview.return_value.settings = Mock(return_value={'syntax': 'Packages/User/PHP.sublime-syntax'})
    mview.return_value.file_name = Mock(return_value='php_file_name')
    return mview()


@pytest.fixture
def invalid_syntax_view():
    mview = Mock()
    mview.return_value.settings = Mock(return_value={'syntax': 'invalid_syntax'})
    mview.return_value.file_name = Mock(return_value='invalid_file_name')
    return mview()
开发者ID:akalongman,项目名称:sublimetext-codeformatter,代码行数:33,代码来源:conftest.py


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