本文整理匯總了Python中mock.__name__方法的典型用法代碼示例。如果您正苦於以下問題:Python mock.__name__方法的具體用法?Python mock.__name__怎麽用?Python mock.__name__使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類mock
的用法示例。
在下文中一共展示了mock.__name__方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_spec_class
# 需要導入模塊: import mock [as 別名]
# 或者: from mock import __name__ [as 別名]
def test_spec_class(self):
class X(object):
pass
mock = Mock(spec=X)
self.assertIsInstance(mock, X)
mock = Mock(spec=X())
self.assertIsInstance(mock, X)
self.assertIs(mock.__class__, X)
self.assertEqual(Mock().__class__.__name__, 'Mock')
mock = Mock(spec_set=X)
self.assertIsInstance(mock, X)
mock = Mock(spec_set=X())
self.assertIsInstance(mock, X)
示例2: test__name__
# 需要導入模塊: import mock [as 別名]
# 或者: from mock import __name__ [as 別名]
def test__name__(self):
mock = Mock()
self.assertRaises(AttributeError, lambda: mock.__name__)
mock.__name__ = 'foo'
self.assertEqual(mock.__name__, 'foo')