本文整理汇总了Python中mock.NonCallableMock.is_valid方法的典型用法代码示例。如果您正苦于以下问题:Python NonCallableMock.is_valid方法的具体用法?Python NonCallableMock.is_valid怎么用?Python NonCallableMock.is_valid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mock.NonCallableMock
的用法示例。
在下文中一共展示了NonCallableMock.is_valid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _inject_mock_invalid_consumer
# 需要导入模块: from mock import NonCallableMock [as 别名]
# 或者: from mock.NonCallableMock import is_valid [as 别名]
def _inject_mock_invalid_consumer(self, uuid=None):
"""For chaning injected consumer identity to one that fails is_valid()
Returns the injected identity if it need to be examined.
"""
invalid_identity = NonCallableMock(name='InvalidIdentityMock')
invalid_identity.is_valid = Mock(return_value=False)
invalid_identity.uuid = uuid or "INVALIDCONSUMERUUID"
inj.provide(inj.IDENTITY, invalid_identity)
return invalid_identity
示例2: _inject_mock_valid_consumer
# 需要导入模块: from mock import NonCallableMock [as 别名]
# 或者: from mock.NonCallableMock import is_valid [as 别名]
def _inject_mock_valid_consumer(self, uuid=None):
"""For changing injected consumer identity to one that passes is_valid()
Returns the injected identity if it need to be examined.
"""
identity = NonCallableMock(name='ValidIdentityMock')
identity.uuid = uuid or "VALIDCONSUMERUUID"
identity.is_valid = Mock(return_value=True)
identity.cert_dir_path = "/not/a/real/path/to/pki/consumer/"
inj.provide(inj.IDENTITY, identity)
return identity