本文整理汇总了Python中unittest.mock.__iter__方法的典型用法代码示例。如果您正苦于以下问题:Python mock.__iter__方法的具体用法?Python mock.__iter__怎么用?Python mock.__iter__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unittest.mock
的用法示例。
在下文中一共展示了mock.__iter__方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_dir
# 需要导入模块: from unittest import mock [as 别名]
# 或者: from unittest.mock import __iter__ [as 别名]
def test_dir(self):
mock = Mock()
attrs = set(dir(mock))
type_attrs = set([m for m in dir(Mock) if not m.startswith('_')])
# all public attributes from the type are included
self.assertEqual(set(), type_attrs - attrs)
# creates these attributes
mock.a, mock.b
self.assertIn('a', dir(mock))
self.assertIn('b', dir(mock))
# instance attributes
mock.c = mock.d = None
self.assertIn('c', dir(mock))
self.assertIn('d', dir(mock))
# magic methods
mock.__iter__ = lambda s: iter([])
self.assertIn('__iter__', dir(mock))
示例2: __iter__
# 需要导入模块: from unittest import mock [as 别名]
# 或者: from unittest.mock import __iter__ [as 别名]
def __iter__(self):
return self