From c39f89960a372026334b93b219c63ef821d932f5 Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Tue, 24 Mar 2026 16:20:08 +0100 Subject: [PATCH] [Python] Replace more equality checks with identity checks This is continuing the preparation for the more strict comparison operator implementation in cppyy. --- .../pyroot/cppyy/cppyy/test/test_advancedcpp.py | 16 ++++++++-------- .../pyroot/cppyy/cppyy/test/test_datatypes.py | 2 +- .../pyroot/cppyy/cppyy/test/test_regression.py | 2 +- roottest/python/cpp/PyROOT_cpptests.py | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bindings/pyroot/cppyy/cppyy/test/test_advancedcpp.py b/bindings/pyroot/cppyy/cppyy/test/test_advancedcpp.py index 0b6ba190a79c0..03307937c8ab1 100644 --- a/bindings/pyroot/cppyy/cppyy/test/test_advancedcpp.py +++ b/bindings/pyroot/cppyy/cppyy/test/test_advancedcpp.py @@ -445,10 +445,10 @@ def test09_opaque_pointer_passing(self): #assert o == cppyy.bind_object(cobj, o.__class__) #assert o == cppyy.bind_object(cobj, "some_concrete_class") assert cppyy.addressof(o) == cppyy.addressof(cppyy.bind_object(addr, some_concrete_class)) - assert o == cppyy.bind_object(addr, some_concrete_class) - assert o == cppyy.bind_object(addr, type(o)) - assert o == cppyy.bind_object(addr, o.__class__) - assert o == cppyy.bind_object(addr, "some_concrete_class") + assert o is cppyy.bind_object(addr, some_concrete_class) + assert o is cppyy.bind_object(addr, type(o)) + assert o is cppyy.bind_object(addr, o.__class__) + assert o is cppyy.bind_object(addr, "some_concrete_class") raises(TypeError, cppyy.bind_object, addr, "does_not_exist") raises(TypeError, cppyy.bind_object, addr, 1) @@ -531,13 +531,13 @@ def test12_actual_type(self): b = base_class() d = derived_class() - assert b == b.cycle(b) + assert b is b.cycle(b) assert id(b) == id(b.cycle(b)) - assert b == d.cycle(b) + assert b is d.cycle(b) assert id(b) == id(d.cycle(b)) - assert d == b.cycle(d) + assert d is b.cycle(d) assert id(d) == id(b.cycle(d)) - assert d == d.cycle(d) + assert d is d.cycle(d) assert id(d) == id(d.cycle(d)) assert isinstance(b.cycle(b), base_class) diff --git a/bindings/pyroot/cppyy/cppyy/test/test_datatypes.py b/bindings/pyroot/cppyy/cppyy/test/test_datatypes.py index 1404a5d99148d..f82d79969c8d5 100644 --- a/bindings/pyroot/cppyy/cppyy/test/test_datatypes.py +++ b/bindings/pyroot/cppyy/cppyy/test/test_datatypes.py @@ -644,7 +644,7 @@ def test09_global_ptr(self): d = gbl.get_global_pod() assert gbl.is_global_pod(d) - assert c == d + assert c is d assert id(c) == id(d) e = gbl.CppyyTestPod() diff --git a/bindings/pyroot/cppyy/cppyy/test/test_regression.py b/bindings/pyroot/cppyy/cppyy/test/test_regression.py index 53e454879845d..a3cc699609df8 100644 --- a/bindings/pyroot/cppyy/cppyy/test/test_regression.py +++ b/bindings/pyroot/cppyy/cppyy/test/test_regression.py @@ -253,7 +253,7 @@ def test11_cobject_addressing(self): a = cppyy.gbl.CObjA() co = cppyy.ll.as_cobject(a) - assert a == cppyy.bind_object(co, 'CObjA') + assert a is cppyy.bind_object(co, 'CObjA') assert a.m_int == 42 assert cppyy.bind_object(co, 'CObjA').m_int == 42 diff --git a/roottest/python/cpp/PyROOT_cpptests.py b/roottest/python/cpp/PyROOT_cpptests.py index a8a3185562f31..afdccf9027588 100644 --- a/roottest/python/cpp/PyROOT_cpptests.py +++ b/roottest/python/cpp/PyROOT_cpptests.py @@ -229,7 +229,7 @@ def test12VoidPointerPassing( self ): self.assertEqual( oaddr, Z.GimeAddressPtrRef( o ) ) pZ = Z.getZ(1) - self.assertEqual( pZ , Z.getZ(1) ) + self.assertIs( pZ , Z.getZ(1) ) import array # Not supported in p2.2