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


Python pymock.Controller类代码示例

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


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

示例1: testRecord

	def testRecord(self):
		"""Verify recording of a new action"""
		c = Controller()
		action = BaseAction('x')
		c.record(action)
		self.failUnless(c.actions.contains(action))
		self.failUnless(c.actionUnderConstruction == action)
开发者ID:agilist,项目名称:springmemo,代码行数:7,代码来源:test_pymock.py

示例2: testSettingClassMethod

	def testSettingClassMethod(self):
		c = Controller()
		class MethodTarget(object):
			def m(self):
				pass
		mt = MethodTarget()
		c.override(mt, 'm', lambda(x): x)
开发者ID:agilist,项目名称:springmemo,代码行数:7,代码来源:test_pymock.py

示例3: testPlayModeAndSwitches

	def testPlayModeAndSwitches(self):
	    """Verify that the replay switch works"""
	    c = Controller()
	    self.failUnless(c.isRecording)
	    self.failIf(c.isPlayingBack)
	    c.replay()
	    self.failIf(c.isRecording)
	    self.failUnless(c.isPlayingBack)
开发者ID:agilist,项目名称:springmemo,代码行数:8,代码来源:test_pymock.py

示例4: testSetCount

	def testSetCount(self):
		"""Verify that settting the count works"""
		c = Controller()
		a = BaseAction('x')
		c.record(a)
		self.failUnless(a.playbackPolicy.remaining == 1)
		c.setCount(2)
		self.failUnless(a.playbackPolicy.remaining == 2)
开发者ID:agilist,项目名称:springmemo,代码行数:8,代码来源:test_pymock.py

示例5: testUnusedAttributeAssignmentCanBeVerified

	def testUnusedAttributeAssignmentCanBeVerified(self):
	    """Ensure that unused calls cause verification failure"""
	    
	    c = Controller()
	    x = c.mock(KlassBeingMocked)
	    x.w = 5
	    c.replay()
	    self.failUnlessRaises(RecordedCallsWereNotReplayedCorrectly, c.verify)
开发者ID:agilist,项目名称:springmemo,代码行数:8,代码来源:test_pymock.py

示例6: testPlayback

	def testPlayback(self):
		"""Ensure that the playback operates correctly"""
		c = Controller()
		action = BaseAction('x')
		c.actions.append(action)
		c.playback(action)
		self.failIf(c.actions.contains(action))
		self.failUnless(action.playbackPolicy.hasBeenPlayedBack)
		self.failUnless(action.playbackPolicy.isReadyForRemoval)
开发者ID:agilist,项目名称:springmemo,代码行数:9,代码来源:test_pymock.py

示例7: testOverrideOfOneItem

	def testOverrideOfOneItem(self):
		"""Verify override stores and replays"""
		c = Controller()
		x = KlassBeingMocked()
		x.f = 38
		c.override(x, 'f', 5)
		self.failUnless(x.f == 5)
		c.restore()
		self.failUnless(x.f == 38)
开发者ID:agilist,项目名称:springmemo,代码行数:9,代码来源:test_pymock.py

示例8: testAttributeAssignmentCanBePlayedBack

	def testAttributeAssignmentCanBePlayedBack(self):
	    """Attibute assignment should be intercepted"""
	    
	    c = Controller()
	    x = c.mock(KlassBeingMocked)
	    x.w = 5
	    x.w = 6
	    c.replay()
	    x.w = 5
开发者ID:agilist,项目名称:springmemo,代码行数:9,代码来源:test_pymock.py

示例9: testUndefinedPlaybackRaisesException

	def testUndefinedPlaybackRaisesException(self):
		"""Playback failure should raise an exception"""	
		c = Controller()
		x = c.mock(KlassBeingMocked)
		c.replay()
		try:
			x.w = 5
			self.fail()
		except PlaybackFailure, e:
			pass
开发者ID:agilist,项目名称:springmemo,代码行数:10,代码来源:test_pymock.py

示例10: testSetAttributeRecordsField

	def testSetAttributeRecordsField(self):
	    """Ensure setting an attribute is correctly recorded"""
	
	    c = Controller()
	    x = c.mock(KlassBeingMocked)
	    x.w = 5
	    self.failUnless(len(c.actions) == 1)
	    action = c.actions.get(BaseAction((x,'w')))
	    self.failUnless(action.field == 'w')
	    self.failUnless(action.value == 5)
开发者ID:agilist,项目名称:springmemo,代码行数:10,代码来源:test_pymock.py

示例11: testFunctionCallWithMismatchedArguments

	def testFunctionCallWithMismatchedArguments(self):
		"""Function call with mismatched arguments"""
		c = Controller()
		x = c.mock(KlassBeingMocked)
		x.g(3, 4)
		x.h()
		x.i(8, v1=4, v2=3)
		c.replay()
		self.failUnlessRaises(PlaybackFailure, x.g, 5, 3)
		self.failUnlessRaises(PlaybackFailure, x.h, 2)
		self.failUnlessRaises(PlaybackFailure, x.i, 8, v1=4, v2=5)
开发者ID:agilist,项目名称:springmemo,代码行数:11,代码来源:test_pymock.py

示例12: testSetCountOneOrMoreRaisesErrorOnNextRecord

	def testSetCountOneOrMoreRaisesErrorOnNextRecord(self):
		"""Setting an unlimited count causes subsequent records to fail"""
		c = Controller()
		x = c.mock(KlassBeingMocked)
		x.w = 5
		c.oneOrMore()
		try:
			x.w = 6
			self.fail()
		except IllegalPlaybackRecorded, e:
			pass
开发者ID:agilist,项目名称:springmemo,代码行数:11,代码来源:test_pymock.py

示例13: testGetattrWithNoReturnValueSpecified

	def testGetattrWithNoReturnValueSpecified(self):
		"""Getattr with no return value specified"""
		c = Controller()
		x = c.mock(KlassBeingMocked)
		x.g
		c.replay()
		self.failIf(x.g == None)
		try:
			x.g
			self.fail()
		except PlaybackFailure, e:
			pass
开发者ID:agilist,项目名称:springmemo,代码行数:12,代码来源:test_pymock.py

示例14: testAttributeAssignmentIsIntercepted

	def testAttributeAssignmentIsIntercepted(self):
	    """Attibute assignment should be intercepted"""
	    
	    c = Controller()
	    x = c.mock(KlassBeingMocked)
	    x.w = 5
	    c.replay()
	    try:
	        x.w
	        self.fail()
	    except PlaybackFailure, e:
	        pass
开发者ID:agilist,项目名称:springmemo,代码行数:12,代码来源:test_pymock.py

示例15: testPlaybackFailsWithIncorrectValues

	def testPlaybackFailsWithIncorrectValues(self):
	    """Ensure playing back incorrect values results in an error"""
	
	    c = Controller()
	    x = c.mock(KlassBeingMocked)
	    x.w = 5
	    c.replay()
	    try:
	        x.w = 4
	        self.fail()
	    except PlaybackFailure, e:
	        pass
开发者ID:agilist,项目名称:springmemo,代码行数:12,代码来源:test_pymock.py


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