Python: use hash() as temporary workaround to check if two objects with different wrappers are underneath the same.
This commit is contained in:
@@ -21,7 +21,7 @@ else:
|
||||
os.environ['PYTHONPATH'] = LOCAL_PYBINDGEN_PATH
|
||||
|
||||
## https://launchpad.net/pybindgen/
|
||||
REQUIRED_PYBINDGEN_VERSION = (0, 8, 0, 516)
|
||||
REQUIRED_PYBINDGEN_VERSION = (0, 9, 0, 526)
|
||||
REQUIRED_PYGCCXML_VERSION = (0, 9, 5)
|
||||
|
||||
|
||||
|
||||
@@ -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