Python: use hash() as temporary workaround to check if two objects with different wrappers are underneath the same.
This commit is contained in:
@@ -105,8 +105,22 @@ class TestSimulator(unittest.TestCase):
|
||||
ptr = ns3.PointerValue()
|
||||
mobility.GetAttribute("Position", ptr)
|
||||
self.assert_(ptr.GetObject() is not None)
|
||||
|
||||
|
||||
def testIdentity(self):
|
||||
csma = ns3.CsmaNetDevice()
|
||||
channel = ns3.CsmaChannel()
|
||||
csma.Attach(channel)
|
||||
|
||||
c1 = csma.GetChannel()
|
||||
c2 = csma.GetChannel()
|
||||
|
||||
## FIXME: it is a PyBindGen bug that comparison via hash
|
||||
## functions is required. However it should be noted that
|
||||
## hash(channel) here basically returns the self->obj pointer,
|
||||
## so if hash(c1) == hash(c2) then we know for sure that c1
|
||||
## and c2 are the same channel, even if with different python
|
||||
## wrappers.
|
||||
self.assertEqual(hash(c1), hash(c2))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user