当前位置: 首页>>代码示例>>Python>>正文


Python Controller.setException方法代码示例

本文整理汇总了Python中pymock.Controller.setException方法的典型用法代码示例。如果您正苦于以下问题:Python Controller.setException方法的具体用法?Python Controller.setException怎么用?Python Controller.setException使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pymock.Controller的用法示例。


在下文中一共展示了Controller.setException方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testExceptionRaisedByFunctions

# 需要导入模块: from pymock import Controller [as 别名]
# 或者: from pymock.Controller import setException [as 别名]
	def testExceptionRaisedByFunctions(self):
		"""Ensure that function calls play back exceptions"""
		c = Controller()
		x = c.mock(KlassBeingMocked)
		x.g.h(3, 4)
		c.setException(Exception)
		c.replay()
		self.failUnlessRaises(Exception, x.g.h, 3, 4)
开发者ID:agilist,项目名称:springmemo,代码行数:10,代码来源:test_pymock.py

示例2: testIterDoesNotAllowRecordingAfterAnException

# 需要导入模块: from pymock import Controller [as 别名]
# 或者: from pymock.Controller import setException [as 别名]
	def testIterDoesNotAllowRecordingAfterAnException(self):
		"""Ensure that __iter__ records and replays exceptions"""
		c = Controller()
		x = c.mock()
		x.__iter__()
		c.setReturn(1)
		c.setException(Exception)
		self.failUnlessRaises(Exception, c.setReturn, 2)
		self.failUnlessRaises(Exception, c.setException, Exception)
开发者ID:agilist,项目名称:springmemo,代码行数:11,代码来源:test_pymock.py

示例3: testIterWithException

# 需要导入模块: from pymock import Controller [as 别名]
# 或者: from pymock.Controller import setException [as 别名]
	def testIterWithException(self):
		"""Ensure that __iter__ records and replays exceptions"""
		c = Controller()
		x = c.mock()
		x.__iter__()
		c.setReturn(1)
		c.setException(Exception)
		c.replay()
		i = x.__iter__()
		self.failUnless(i.next() == 1)
		self.failUnlessRaises(Exception, i.next)
开发者ID:agilist,项目名称:springmemo,代码行数:13,代码来源:test_pymock.py

示例4: testExplicitGeneratorExecptionUsage

# 需要导入模块: from pymock import Controller [as 别名]
# 或者: from pymock.Controller import setException [as 别名]
	def testExplicitGeneratorExecptionUsage(self):
		"""Check exception raising with explicit generators using discrete settings"""
		c = Controller()
		x = c.mock()
		x.g(8, 9)
		c.generator()
		c.setReturn(10)
		c.setException(Exception("bogus"))
		c.replay()
		g = x.g(8, 9)
		self.failUnless(g.next() == 10)
		self.failUnlessRaises(Exception, g.next)
开发者ID:agilist,项目名称:springmemo,代码行数:14,代码来源:test_pymock.py

示例5: testExceptionRaisedBySetattr

# 需要导入模块: from pymock import Controller [as 别名]
# 或者: from pymock.Controller import setException [as 别名]
	def testExceptionRaisedBySetattr(self):
		"""Ensure that setattr returns function calls"""
		c = Controller()
		x = c.mock(KlassBeingMocked)
		x.g = 6
		c.setException(Exception)
		c.replay()
		try:
			x.g = 6
			self.fail()
		except Exception, e:
			pass
开发者ID:agilist,项目名称:springmemo,代码行数:14,代码来源:test_pymock.py

示例6: testExceptionRaisedByGetattr

# 需要导入模块: from pymock import Controller [as 别名]
# 或者: from pymock.Controller import setException [as 别名]
	def testExceptionRaisedByGetattr(self):
		"""Ensure that getattr plays back exceptions"""
		c = Controller()
		x = c.mock(KlassBeingMocked)
		x.g
		c.setException(Exception)
		c.replay()
		try:
			x.g
			self.fail()
		except Exception, e:
			pass
开发者ID:agilist,项目名称:springmemo,代码行数:14,代码来源:test_pymock.py


注:本文中的pymock.Controller.setException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。