Ejemplo n.º 1
0
 def testSpyOnOverriddenBaseClassMethod(self):
     SpySubClass = spyable(
         methods=[NewBaseClass.eatCorn, "mymethod"])(SubClassWithOverride)
     z = SpySubClass('a', 'b')
     z.mymethod("hi")
     z.eatCorn("canned")
     self.assertEqual(z.spylog.getLast('eatCorn'), None)
     self.assertEqual(
         z.spylog.getLast('mymethod')[pr], ({
             'inp': 'hi'
         }, None))
Ejemplo n.º 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.assertEqual(z.spylog.getLast('eatCorn'), None)
     self.assertEqual(
         z.spylog.getLast('mymethod')[pr], ({
             'inp': 'hi'
         }, None))
Ejemplo n.º 3
0
 def go(methods, ec: "expected counts"):
     SpySubClass = spyable(methods=methods)(SubClass)
     z = SpySubClass('a', 'b')
     self.assertEqual(
         len(z.spylog), ec[0],
         "expected certain number of entries in the spy log")
     z.eatCorn('canned')
     z.eatCorn('whirled')
     self.assertEqual(
         len(z.spylog), ec[1],
         "expected certain number of entries in the spy log")
     z.eatCorn('creamed')
     z.mymethod("hello again")
     self.assertEqual(
         len(z.spylog), ec[2],
         "expected certain number of entries in the spy log")
Ejemplo n.º 4
0
 def testSpyableSubClassWithOverride(self):
     SpySubClassOvrd = spyable()(SubClassWithOverride)
     z = SpySubClassOvrd('x', 'y')
     self.runThroughAssertions(z, 'hooray!')
Ejemplo n.º 5
0
 def testSpyableSubClass(self):
     SpySubClass = spyable()(SubClass)
     z = SpySubClass('x', 'y')
     self.runThroughAssertions(z)
Ejemplo n.º 6
0
 def testSpyableBaseClass(self):
     SpyBaseClass = spyable()(NewBaseClass)
     z = SpyBaseClass('x', 'y')
     self.runThroughAssertions(z)
Ejemplo n.º 7
0
 def testNew(self):
     X = spyable(Node)
     print(X)
Ejemplo n.º 8
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'})