From 27df0a5c92ac468b01ec2ac93ef29b86b951bb4e Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Fri, 1 Aug 2008 23:11:42 +0100 Subject: [PATCH] Python: use hash() as temporary workaround to check if two objects with different wrappers are underneath the same. --- bindings/python/wscript | 2 +- utils/python-unit-tests.py | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/bindings/python/wscript b/bindings/python/wscript index c691e3fc1..799fa5e82 100644 --- a/bindings/python/wscript +++ b/bindings/python/wscript @@ -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) diff --git a/utils/python-unit-tests.py b/utils/python-unit-tests.py index 18d6b5d96..623b16b7c 100644 --- a/utils/python-unit-tests.py +++ b/utils/python-unit-tests.py @@ -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()