-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added python bindings test for mutable object conversion
- Loading branch information
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import unittest | ||
import ROOT | ||
|
||
res = ROOT.gSystem.Load("libTestDataModel.so") | ||
if res < 0: | ||
raise RuntimeError("Failed to load libTestDataModel.so") | ||
|
||
from ROOT import MutableExampleMC | ||
from ROOT import ExampleMCCollection | ||
|
||
|
||
class Test_ObjectConversions(unittest.TestCase): | ||
def test_conversion_mutable_to_immutable(self): | ||
ROOT.gInterpreter.Declare( | ||
""" | ||
void test_accepts_immutable(ExampleMC) {} | ||
""" | ||
) | ||
accepts_immutable = ROOT.test_accepts_immutable | ||
mutable_obj = MutableExampleMC() | ||
accepts_immutable(mutable_obj) | ||
|
||
|
||
class Test_OneToManyRelations(unittest.TestCase): | ||
def test_add(self): | ||
particles = ExampleMCCollection() | ||
parent_particle = particles.create() | ||
daughter_particle = particles.create() | ||
|
||
self.assertEqual(len(daughter_particle.parents()), 0) | ||
daughter_particle.addparents(parent_particle) | ||
self.assertEqual(len(daughter_particle.parents()), 1) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |