def testNullifyHandle(self): s = Standard_Transient() self.assertEqual(s.GetRefCount(), 0) # create an hanle from this transient. RefCount is incremented h = s.GetHandle() self.assertEqual(h.IsNull(), False) self.assertEqual(s.GetRefCount(), 1) # if this handle is nullified, refcount is decremented h.Nullify() self.assertEqual(h.IsNull(), True) self.assertEqual(s.GetRefCount(), 0)
def test_neq_operator(self): # test Standard h1 = Handle_Standard_Transient() s = Standard_Transient() h2 = s.GetHandle() self.assertFalse(h1 != h1) self.assertTrue(h1 != h2) self.assertTrue(h1 != 10) self.assertFalse(h2 != s) shape_1 = BRepPrimAPI_MakeBox(10, 20, 30).Shape() shape_2 = BRepPrimAPI_MakeBox(10, 20, 30).Shape() self.assertTrue(shape_1 != shape_2) self.assertFalse(shape_1 != shape_1) self.assertTrue(shape_1 != "some_string")
def test_hash_eq_operator(self): ''' test that the == wrapper is ok ''' # test Standard h1 = Handle_Standard_Transient() s = Standard_Transient() h2 = s.GetHandle() self.assertTrue(h1 == h1) self.assertFalse(h1 == h2) self.assertFalse(h1 == 10) self.assertTrue(h2 == s) # test list.index, that uses __eq__ method p1 = gp_Pnt(0., 0., 0.) line = gp_Lin(p1, gp_Dir(1., 0., 0.)) items = [p1, line] res = items.index(line) self.assertEqual(res, 1.)