Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
Root
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
为了安全,强烈建议开启2FA双因子认证:User Settings -> Account -> Enable two-factor authentication!!!
Show more breadcrumbs
cxwx
Root
Commits
a7612f9e
Commit
a7612f9e
authored
6 years ago
by
Enric Tejedor Saavedra
Browse files
Options
Downloads
Patches
Plain Diff
[Exp PyROOT] Test contains pythonisation for TObject
parent
5137397e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bindings/pyroot_experimental/PyROOT/test/CMakeLists.txt
+3
-0
3 additions, 0 deletions
bindings/pyroot_experimental/PyROOT/test/CMakeLists.txt
bindings/pyroot_experimental/PyROOT/test/tobject_contains.py
+44
-0
44 additions, 0 deletions
bindings/pyroot_experimental/PyROOT/test/tobject_contains.py
with
47 additions
and
0 deletions
bindings/pyroot_experimental/PyROOT/test/CMakeLists.txt
+
3
−
0
View file @
a7612f9e
...
@@ -2,6 +2,9 @@
...
@@ -2,6 +2,9 @@
ROOT_ADD_PYUNITTEST
(
pyroot_pyz_pretty_printing pretty_printing.py
)
ROOT_ADD_PYUNITTEST
(
pyroot_pyz_pretty_printing pretty_printing.py
)
ROOT_ADD_PYUNITTEST
(
pyroot_pyz_array_interface array_interface.py
)
ROOT_ADD_PYUNITTEST
(
pyroot_pyz_array_interface array_interface.py
)
# TObject and subclasses pythonisations
ROOT_ADD_PYUNITTEST
(
pyroot_pyz_tobject_contains tobject_contains.py
)
# TDirectory and subclasses pythonizations
# TDirectory and subclasses pythonizations
ROOT_ADD_PYUNITTEST
(
pyroot_pyz_tdirectory_attrsyntax tdirectory_attrsyntax.py
)
ROOT_ADD_PYUNITTEST
(
pyroot_pyz_tdirectory_attrsyntax tdirectory_attrsyntax.py
)
ROOT_ADD_PYUNITTEST
(
pyroot_pyz_tdirectoryfile_attrsyntax_get tdirectoryfile_attrsyntax_get.py
)
ROOT_ADD_PYUNITTEST
(
pyroot_pyz_tdirectoryfile_attrsyntax_get tdirectoryfile_attrsyntax_get.py
)
...
...
This diff is collapsed.
Click to expand it.
bindings/pyroot_experimental/PyROOT/test/tobject_contains.py
0 → 100644
+
44
−
0
View file @
a7612f9e
import
unittest
import
ROOT
from
libcppyy
import
SetOwnership
class
TObjectContains
(
unittest
.
TestCase
):
"""
Test for the __contains__ pythonisation of TObject and subclasses.
Such pythonisation relies on TObject::FindObject, which is redefined
in some of its subclasses, such as TCollection.
Thanks to this pythonisation, we can use the syntax `obj in col`
to know if col contains obj.
"""
num_elems
=
3
# Helpers
def
create_tlist
(
self
):
l
=
ROOT
.
TList
()
for
_
in
range
(
self
.
num_elems
):
o
=
ROOT
.
TObject
()
# Prevent immediate deletion of C++ TObjects
SetOwnership
(
o
,
False
)
l
.
Add
(
o
)
return
l
# Tests
def
test_contains
(
self
):
l
=
self
.
create_tlist
()
for
elem
in
l
:
self
.
assertTrue
(
elem
in
l
)
# Make sure it does not work just because of __iter__
self
.
assertTrue
(
l
.
__contains__
(
elem
))
o
=
ROOT
.
TObject
()
self
.
assertFalse
(
o
in
l
)
self
.
assertFalse
(
l
.
__contains__
(
o
))
if
__name__
==
'
__main__
'
:
unittest
.
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment