Skip to content
Snippets Groups Projects
Commit e1e7b9e3 authored by Enric Tejedor Saavedra's avatar Enric Tejedor Saavedra
Browse files

[Exp PyROOT] Add test for len in TCollection and subclasses

parent b8221e84
No related branches found
No related tags found
No related merge requests found
...@@ -16,3 +16,6 @@ ROOT_ADD_PYUNITTEST(pyroot_pyz_ttree_setbranchaddress ttree_setbranchaddress.py ...@@ -16,3 +16,6 @@ ROOT_ADD_PYUNITTEST(pyroot_pyz_ttree_setbranchaddress ttree_setbranchaddress.py
COPY_TO_BUILDDIR TreeHelper.h) COPY_TO_BUILDDIR TreeHelper.h)
ROOT_ADD_PYUNITTEST(pyroot_pyz_ttree_branch ttree_branch.py ROOT_ADD_PYUNITTEST(pyroot_pyz_ttree_branch ttree_branch.py
COPY_TO_BUILDDIR TreeHelper.h) COPY_TO_BUILDDIR TreeHelper.h)
# TCollection and subclasses pythonizations
ROOT_ADD_PYUNITTEST(pyroot_pyz_tcollection_len tcollection_len.py)
import unittest
import ROOT
class TCollectionLen(unittest.TestCase):
"""
Test for the pythonization that allows to access the number of elements of a
TCollection (or subclass) by calling `len` on it.
"""
num_elems = 3
tobject_list = [ ROOT.TObject() for _ in range(num_elems) ]
# Helpers
def add_elems_check_len(self, c):
for elem in self.tobject_list:
c.Add(elem)
self.assertEqual(len(c), self.num_elems)
self.assertEqual(len(c), c.GetEntries())
# Tests
def test_tlist(self):
self.add_elems_check_len(ROOT.TList())
def test_tobjarray(self):
self.add_elems_check_len(ROOT.TObjArray())
def test_thashtable(self):
self.add_elems_check_len(ROOT.THashTable())
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment