def testReimplementedProtectedCall(self): '''Calls a reimplemented virtual protected method from parent class.''' original_name = 'Poly' p = ExtendedProtectedPolymorphicDaughter(original_name) name = p.callProtectedName() self.assertTrue(p.protectedName_called) self.assertEqual(p.protectedName(), name) self.assertEqual(ProtectedPolymorphicDaughter.protectedName(p), original_name)
def testReimplementedProtectedCall(self): '''Calls a reimplemented virtual protected method from parent class.''' original_name = 'Poly' p = ExtendedProtectedPolymorphicDaughter(original_name) name = p.callProtectedName() self.assert_(p.protectedName_called) self.assertEqual(p.protectedName(), name) self.assertEqual(ProtectedPolymorphicDaughter.protectedName(p), original_name)
def protectedName(self): self.protectedName_called = True self._name = 'ExtendedDaughter' + ProtectedPolymorphicDaughter.protectedName( self) return self._name
def __init__(self, name): self.protectedName_called = False ProtectedPolymorphicDaughter.__init__(self, name)
def testProtectedCallWithInstanceCreatedOnCpp(self): '''Calls a virtual protected method from parent class on an instance created in C++.''' p = ProtectedPolymorphicDaughter.create() self.assertEqual(p.publicName(), p.protectedName()) self.assertEqual(p.callProtectedName(), p.protectedName())
def protectedName(self): self.protectedName_called = True self._name = 'ExtendedDaughter' + ProtectedPolymorphicDaughter.protectedName(self) return self._name