forked from AIDASoft/podio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: mutable to immutable object conversion with python bindings (AID…
…ASoft#564) * added python bindings test for mutable object conversion * replaced object conversion function with converting constructor * ignore emplace_back clang-tidy suggestion in test
- Loading branch information
Showing
6 changed files
with
38 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env python3 | ||
"""cppyy python binding tests""" | ||
|
||
import unittest | ||
import ROOT | ||
from ROOT import ExampleMCCollection, MutableExampleMC | ||
|
||
|
||
class ObjectConversionsTest(unittest.TestCase): | ||
"""Object conversion binding tests""" | ||
|
||
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 OneToManyRelationsTest(unittest.TestCase): | ||
"""OneToManyRelations binding tests""" | ||
|
||
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) |
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
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
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