Python: use hash() as temporary workaround to check if two objects with different wrappers are underneath the same.
authorGustavo J. A. M. Carneiro <gjc@inescporto.pt>
Fri, 01 Aug 2008 23:11:42 +0100
changeset 3501 f725f0e0d6b7
parent 3497 b459941d6287
child 3502 794671c6a8a1
Python: use hash() as temporary workaround to check if two objects with different wrappers are underneath the same.
bindings/python/wscript
utils/python-unit-tests.py
--- a/bindings/python/wscript	Wed Jul 30 16:36:57 2008 -0400
+++ b/bindings/python/wscript	Fri Aug 01 23:11:42 2008 +0100
@@ -21,7 +21,7 @@
     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)
 
 
--- a/utils/python-unit-tests.py	Wed Jul 30 16:36:57 2008 -0400
+++ b/utils/python-unit-tests.py	Fri Aug 01 23:11:42 2008 +0100
@@ -105,8 +105,22 @@
         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()