Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
test_base.py
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file test_base.py
1 import pytest
2 
3 import acts
4 
5 import acts.examples
6 
7 
9  for l in ("VERBOSE", "DEBUG", "INFO", "WARNING", "ERROR", "FATAL"):
10  assert hasattr(acts.logging, l)
11  assert hasattr(acts.logging.Level, l)
12 
13 
15  assert len(acts.PdgParticle.__members__) == 17
16 
17 
19  v3 = acts.Vector3(1, 2, 3)
20  with pytest.raises(TypeError):
21  acts.Vector3(1, 2, 3, 4)
22  with pytest.raises(TypeError):
23  acts.Vector3(1, 2)
24 
25  v3 = acts.Vector3([1, 2, 3])
26  with pytest.raises(TypeError):
27  acts.Vector3([1, 2, 3, 4])
28  with pytest.raises(TypeError):
29  acts.Vector3([1, 2])
30  with pytest.raises(TypeError):
31  acts.Vector3()
32 
33  v4 = acts.Vector4(1, 2, 3, 4)
34  with pytest.raises(TypeError):
35  v4 = acts.Vector4(1, 2, 3)
36  v4 = acts.Vector4([1, 2, 3, 4])
37  with pytest.raises(TypeError):
38  acts.Vector4([1, 2, 3])
39  with pytest.raises(TypeError):
40  acts.Vector4()
41 
42 
43 def test_empty_sequencer(conf_const):
45  with pytest.raises(RuntimeError):
46  s.run()
47 
48  s = conf_const(acts.examples.Sequencer, events=1)
49  s.run()
50 
51 
52 def test_sequencer_single_threaded(ptcl_gun, capfd):
53  s = acts.examples.Sequencer(numThreads=1, events=2)
54  ptcl_gun(s)
55  s.run()
56  cap = capfd.readouterr()
57  assert cap.err == ""
58  assert "Create Sequencer (single-threaded)" in cap.out
59  assert "Processed 2 events" in cap.out
60 
61 
62 def test_sequencer_multi_threaded(ptcl_gun, capfd):
63  # This test can use 2 threads (for the 2 events),
64  # but could be run single-threaded if threading is not available.
65  s = acts.examples.Sequencer(numThreads=-1, events=2)
66  ptcl_gun(s)
67  s.run()
68  cap = capfd.readouterr()
69  assert cap.err == ""
70  assert "Create Sequencer" in cap.out
71  assert "Processed 2 events" in cap.out
72 
73 
75  rnd = acts.examples.RandomNumbers(seed=42)
76 
77 
80  print(s1)
82  print(s2)