本文整理匯總了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