ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthenaPython
python
tests
test_CA.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2
3
import
AthenaCommon.SystemOfUnits
as
Units
4
from
AthenaConfiguration.AllConfigFlags
import
initConfigFlags
5
from
AthenaConfiguration.ComponentAccumulator
import
ComponentAccumulator
6
from
AthenaConfiguration.ComponentFactory
import
CompFactory
7
from
AthenaConfiguration.MainServicesConfig
import
MainServicesCfg
8
from
AthenaPython.tests.PyTestsLib
import
MyAlg, MySvc, MyTool
9
10
import
unittest
11
12
class
Test
( unittest.TestCase ):
13
def
test_basic
(self):
14
flags = initConfigFlags()
15
flags.lock()
16
17
cfg = MainServicesCfg(flags)
18
cfg.addSequence(CompFactory.AthSequencer(
"MySeq"
))
19
20
cfg.addEventAlgo( MyAlg(
"MyAlg1"
, eta = 2.5, pt = 42.),
21
sequenceName =
"MySeq"
)
22
23
cfg.addEventAlgo( MyAlg(
"MyAlg2"
, eta = 5.1, pt = 20.*Units.GeV, filterPassed =
False
),
24
sequenceName =
"MySeq"
)
25
26
# alg3 should never be executed due to filterPassed of alg2
27
cfg.addEventAlgo( MyAlg(
"MyAlg3"
, eta = 4.9, pt = 15.*Units.GeV,
28
mytool = MyTool(
"MyTool"
, counter = 50, parent=
"MyAlg3"
)),
29
sequenceName =
"MySeq"
)
30
31
cfg.addService( MySvc(), create=
True
)
32
33
with
open(
'test_CA.pkl'
,
'wb'
)
as
f:
34
cfg.store(f)
35
sc = cfg.run(2)
36
self.assertFalse(sc.isFailure())
37
38
def
test_merge
(self):
39
cfg1 = ComponentAccumulator()
40
cfg2 = ComponentAccumulator()
41
cfg1.addEventAlgo( MyAlg(name=
'Alg1'
, px=1) )
42
cfg2.addEventAlgo( MyAlg(name=
'Alg2'
, px=2) )
43
cfg1.merge(cfg2)
44
cfg1.wasMerged()
45
46
def
test_merge_fail
(self):
47
cfg1 = ComponentAccumulator()
48
cfg2 = ComponentAccumulator()
49
cfg1.addEventAlgo( MyAlg(px=1) )
50
cfg2.addEventAlgo( MyAlg(px=2) )
51
with
self.assertRaises(ValueError):
52
cfg1.merge(cfg2)
53
54
55
if
__name__ ==
"__main__"
:
56
unittest.main()
python.tests.test_CA.Test
Definition
test_CA.py:12
python.tests.test_CA.Test.test_merge
test_merge(self)
Definition
test_CA.py:38
python.tests.test_CA.Test.test_basic
test_basic(self)
Definition
test_CA.py:13
python.tests.test_CA.Test.test_merge_fail
test_merge_fail(self)
Definition
test_CA.py:46
Generated on
for ATLAS Offline Software by
1.17.0