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


Python PropertyMock.configure_mock方法代码示例

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


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

示例1: test_update_stores_tp

# 需要导入模块: from mock import PropertyMock [as 别名]
# 或者: from mock.PropertyMock import configure_mock [as 别名]
def test_update_stores_tp(plugin_mock):
    """Site wide update_stores"""
    command = Command()
    tp = PropertyMock()
    tp.configure_mock(
        **{'pootle_path': 'FOO',
           'project': 23})
    command.handle_translation_project(tp, **DEFAULT_OPTIONS)
    assert (
        list(plugin_mock.return_value.add.call_args)
        == [(), {'pootle_path': 'FOO*', 'update': 'pootle'}])
    assert (
        list(plugin_mock.return_value.rm.call_args)
        == [(), {'pootle_path': 'FOO*', 'update': 'pootle'}])
    assert (
        list(plugin_mock.return_value.resolve.call_args)
        == [(), {'pootle_path': 'FOO*', 'merge': True}])
    assert (
        list(plugin_mock.return_value.sync.call_args)
        == [(), {'pootle_path': 'FOO*', 'update': 'pootle'}])
    assert list(plugin_mock.call_args) == [(23,), {}]
开发者ID:arky,项目名称:pootle,代码行数:23,代码来源:update_stores.py

示例2: test_wrap_store_fs_with_store

# 需要导入模块: from mock import PropertyMock [as 别名]
# 或者: from mock.PropertyMock import configure_mock [as 别名]
def test_wrap_store_fs_with_store(valid_mock):
    valid_mock.side_effect = lambda x: x
    store_mock = PropertyMock()
    store_mock.configure_mock(
        **{"data.max_unit_revision": 23,
           "serialize.return_value": 73})
    store_fs = MockStoreFS()
    store_fs.store = store_mock
    fs_file = FSFile(store_fs)

    assert (
        fs_file.file_path
        == os.path.join(
            store_fs.project.local_fs_path,
            store_fs.path.strip("/")))
    assert fs_file.file_exists is False
    assert fs_file.latest_hash is None
    assert fs_file.fs_changed is False
    assert fs_file.pootle_changed is True
    assert fs_file.store is store_mock
    assert fs_file.store_exists is True
    assert fs_file.serialize() == 73
    assert fs_file.deserialize() is None
开发者ID:arky,项目名称:pootle,代码行数:25,代码来源:files.py

示例3: TestGeometry

# 需要导入模块: from mock import PropertyMock [as 别名]
# 或者: from mock.PropertyMock import configure_mock [as 别名]

#.........这里部分代码省略.........
        self.assertEqual(self.geometry.make_location(1.0, 2.0, 3.0), loc)

    def test_get_coordinates(self):
        # Check that retrieving coordinates from `Location` objects works.
        # The supported location types of the geometry are tested.
        loc1 = LocationLocal(1.0, 2.0, -3.0)
        self.assertEqual(self.geometry.get_coordinates(loc1), (1.0, 2.0, 3.0))

        loc2 = self._make_relative_location(4.0, 5.0, 6.0)
        self.assertEqual(self.geometry.get_coordinates(loc2), (4.0, 5.0, 6.0))

        loc3 = self._make_global_location(7.0, 8.0, 9.0)
        self.assertEqual(self.geometry.get_coordinates(loc3), (7.0, 8.0, 9.0))

        # A `Location` object must be provided.
        with self.assertRaises(TypeError):
            self.geometry.get_coordinates(None)

    def test_bearing_to_angle(self):
        bearing = -45.0 * math.pi/180
        self.assertEqual(self.geometry.bearing_to_angle(bearing),
                         135.0 * math.pi/180)

    def test_angle_to_bearing(self):
        angle = 180.0 * math.pi/180
        self.assertEqual(self.geometry.angle_to_bearing(angle),
                         270.0 * math.pi/180)

    def test_get_location_local(self):
        local_location = LocationLocal(7.6, 5.4, -3.2)
        self.assertEqual(self.geometry.get_location_local(local_location),
                         local_location)

        self.local_mock.configure_mock(return_value=local_location)
        self.assertEqual(self.geometry.get_location_local(self.locations_mock),
                         local_location)
        self.local_mock.assert_called_once_with()

    def test_get_location_local_other(self):
        # Base geometry does not support relative or global locations.
        with self.assertRaises(TypeError):
            self.geometry.get_location_local(self.global_location)
        with self.assertRaises(TypeError):
            self.geometry.get_location_local(self.relative_location)

    def test_get_location_frame(self):
        local_location = LocationLocal(7.6, 5.4, -3.2)
        self.local_mock.configure_mock(return_value=local_location)
        self.assertEqual(self.geometry.get_location_frame(self.locations_mock),
                         local_location)
        self.local_mock.assert_called_once_with()

    def test_get_location_frame_other(self):
        # A `Locations` object must be given.
        with self.assertRaises(TypeError):
            self.geometry.get_location_frame(self.local_location)
        with self.assertRaises(TypeError):
            self.geometry.get_location_frame(self.global_location)
        with self.assertRaises(TypeError):
            self.geometry.get_location_frame(self.relative_location)

    def test_get_location_meters(self):
        loc = LocationLocal(5.4, 3.2, -1.0)
        loc2 = LocationLocal(5.4, 3.2, -11.0)
        self.assertEqual(self.geometry.get_location_meters(loc, 0, 0, 0), loc)
        self.assertEqual(self.geometry.get_location_meters(loc, 0, 0, 10), loc2)
开发者ID:lhelwerd,项目名称:mobile-radio-tomography,代码行数:70,代码来源:geometry.py


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