예제 #1
0
 def testSpyOnOverriddenBaseClassMethod(self):
     SpySubClass = Spyable(methods=[NewBaseClass.eatCorn, "mymethod"])(
         SubClassWithOverride)
     z = SpySubClass('a', 'b')
     z.mymethod("hi")
     z.eatCorn("canned")
     self.assertEquals(z.spylog.getLast('eatCorn'), None)
     self.assertEquals(z.spylog.getLast('mymethod')[pr],
                       ({'inp': 'hi'}, None))
예제 #2
0
 def testSpyOnCertainClass(self):
     # known limitation... when super() is called, we are not spy-wrapping
     # base base class methods.
     SpySubClass = Spyable(methods=[NewBaseClass.eatCorn, "mymethod"])(
         SubClassWithOverrideAndSuperCall)
     z = SpySubClass('a', 'b')
     z.mymethod("hi")
     z.eatCorn("canned")
     self.assertEquals(z.spylog.getLast('eatCorn'), None)
     self.assertEquals(z.spylog.getLast('mymethod')[pr], ({'inp': 'hi'},
                                                          None))
예제 #3
0
 def go(methods, ec: "expected counts"):
     SpySubClass = Spyable(methods=methods)(SubClass)
     z = SpySubClass('a', 'b')
     self.assertEquals(len(z.spylog), ec[0],
                       "expected certain number of entries in the spy log")
     z.eatCorn('canned')
     z.eatCorn('whirled')
     self.assertEquals(len(z.spylog), ec[1],
                       "expected certain number of entries in the spy log")
     z.eatCorn('creamed')
     z.mymethod("hello again")
     self.assertEquals(len(z.spylog), ec[2],
                       "expected certain number of entries in the spy log")
예제 #4
0
 def testEveryObjectGetsItsOwnSpyLog(self):
     SpySubClass = Spyable()(SubClass)
     y = SpySubClass('a', 'b')
     z = SpySubClass('x', 'y')
     self.checkOneInit(y, {'s': 'a', 'p': 'b'})
     self.checkOneInit(z, {'s': 'x', 'p': 'y'})
예제 #5
0
 def testSpyableSubClassWithOverride(self):
     SpySubClassOvrd = Spyable()(SubClassWithOverride)
     z = SpySubClassOvrd('x', 'y')
     self.runThroughAssertions(z, 'hooray!')
예제 #6
0
 def testSpyableSubClass(self):
     SpySubClass = Spyable()(SubClass)
     z = SpySubClass('x', 'y')
     self.runThroughAssertions(z)
예제 #7
0
 def testSpyableBaseClass(self):
     SpyBaseClass = Spyable()(NewBaseClass)
     z = SpyBaseClass('x', 'y')
     self.runThroughAssertions(z)
예제 #8
0
 def testNew(self):
     X = Spyable(Node)
     print(X)