當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。