本文整理汇总了Python中mock.sentinel.Something2方法的典型用法代码示例。如果您正苦于以下问题:Python sentinel.Something2方法的具体用法?Python sentinel.Something2怎么用?Python sentinel.Something2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mock.sentinel
的用法示例。
在下文中一共展示了sentinel.Something2方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_with_statement
# 需要导入模块: from mock import sentinel [as 别名]
# 或者: from mock.sentinel import Something2 [as 别名]
def test_with_statement(self):
with patch('%s.something' % __name__, sentinel.Something2):
self.assertEqual(something, sentinel.Something2, "unpatched")
self.assertEqual(something, sentinel.Something)
示例2: test_with_statement_exception
# 需要导入模块: from mock import sentinel [as 别名]
# 或者: from mock.sentinel import Something2 [as 别名]
def test_with_statement_exception(self):
try:
with patch('%s.something' % __name__, sentinel.Something2):
self.assertEqual(something, sentinel.Something2, "unpatched")
raise Exception('pow')
except Exception:
pass
else:
self.fail("patch swallowed exception")
self.assertEqual(something, sentinel.Something)
示例3: test_with_statement_exception
# 需要导入模块: from mock import sentinel [as 别名]
# 或者: from mock.sentinel import Something2 [as 别名]
def test_with_statement_exception(self):
with self.assertRaises(SampleException):
with patch('%s.something' % __name__, sentinel.Something2):
self.assertEqual(something, sentinel.Something2, "unpatched")
raise SampleException()
self.assertEqual(something, sentinel.Something)