本文整理汇总了Python中mock.PropertyMock.assert_called_once方法的典型用法代码示例。如果您正苦于以下问题:Python PropertyMock.assert_called_once方法的具体用法?Python PropertyMock.assert_called_once怎么用?Python PropertyMock.assert_called_once使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mock.PropertyMock
的用法示例。
在下文中一共展示了PropertyMock.assert_called_once方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_store_checks_fullness
# 需要导入模块: from mock import PropertyMock [as 别名]
# 或者: from mock.PropertyMock import assert_called_once [as 别名]
def test_store_checks_fullness(self):
is_full_mock = PropertyMock()
with patch.object(_MetricCache, 'is_full', is_full_mock):
with patch('carbon.cache.events'):
metric_cache = _MetricCache()
metric_cache.store('foo', (123456, 1.0))
is_full_mock.assert_called_once()
示例2: verify_super_property_called_with_wait
# 需要导入模块: from mock import PropertyMock [as 别名]
# 或者: from mock.PropertyMock import assert_called_once [as 别名]
def verify_super_property_called_with_wait(self, prop_name):
"""
Verifies that accessing the given property calls the equally
named property on the super class.
"""
with patch(
'__builtin__.super'
) as mock_super, patch.object(
self.instance, 'wait_for_angular'
) as mock_wait_for_angular:
# setup the mocked property
mock_prop = PropertyMock(name='super.{}'.format(prop_name))
setattr(type(mock_super.return_value), prop_name, mock_prop)
result = getattr(self.instance, prop_name)
mock_wait_for_angular.assert_called_once()
mock_super.assert_called_once_with(WebDriverMixin, self.instance)
mock_prop.assert_called_once()
self.assertIs(result, mock_prop.return_value)
示例3: test_get_scheduler
# 需要导入模块: from mock import PropertyMock [as 别名]
# 或者: from mock.PropertyMock import assert_called_once [as 别名]
def test_get_scheduler(self):
"""Tests successful execution of the get_scheduler command."""
mock_options = self.setup_mock_options()
mock_proxy = Mock(spec=SchedulerProxy)
mock_scheduler_client = Mock(spec=SchedulerClient)
mock_raw_url = PropertyMock(return_value="url")
mock_proxy.scheduler_client.return_value = mock_scheduler_client
mock_scheduler_client.raw_url = mock_raw_url
with contextlib.nested(
patch('twitter.common.app.get_options', return_value=mock_options),
patch('apache.aurora.client.commands.admin.AuroraClientAPI',
new=Mock(spec=AuroraClientAPI)),
patch('apache.aurora.client.commands.admin.CLUSTERS', new=self.TEST_CLUSTERS),
) as (_, api, _):
api.return_value.scheduler_proxy = PropertyMock(return_value=mock_proxy)
get_scheduler([self.TEST_CLUSTER])
mock_raw_url.assert_called_once()