Belle II Software
development
test_check_basf2_file.py
1
#!/usr/bin/env python3
2
3
10
11
import
os
12
13
# Test redirect_stdout, as we use that in b2file-check
14
from
contextlib
import
redirect_stdout
15
with
redirect_stdout(open(os.devnull,
'w'
)):
16
print(
'abc'
)
17
18
import
basf2
# noqa
19
20
21
rootfile = basf2.find_file(
'/framework/tests/root_input.root'
)
22
assert
0 == os.system(
'b2file-check '
+ rootfile)
23
24
assert
0 != os.system(
'b2file-check /THIS_DOESNT_EXIST'
)
25
assert
0 != os.system(
'b2file-check /dev/null'
)
26
27
28
assert
0 == os.system(
'b2file-check -n 5 '
+ rootfile)
29
assert
0 == os.system(
'b2file-check --events 5 '
+ rootfile)
30
assert
0 != os.system(
'b2file-check -n 10 '
+ rootfile)
31
32
assert
0 == os.system(
'b2file-check --mcevents 5 '
+ rootfile)
33
assert
0 != os.system(
'b2file-check --mcevents 0 '
+ rootfile)
34
35
assert
0 == os.system(
'b2file-check -n 5 -s 9.5 1 '
+ rootfile)
36
assert
0 == os.system(
'b2file-check -n 5 -s 9.5 0.05 '
+ rootfile)
37
assert
0 != os.system(
'b2file-check -n 5 -s 9.5 0 '
+ rootfile)
38
39
assert
0 == os.system(
'b2file-check -n 5 -s 10 1 '
+ rootfile)
40
assert
0 == os.system(
'b2file-check -n 5 -s 10 0.5 '
+ rootfile)
41
assert
0 == os.system(
'b2file-check -n 5 -s 10 0.2 '
+ rootfile)
42
assert
0 != os.system(
'b2file-check -n 5 -s 10 0.05 '
+ rootfile)
43
44
assert
0 == os.system(
'b2file-check -n 5 -s 10 0.5 '
+ rootfile +
' EventMetaData'
)
45
allbranches =
'EventMetaData PXDClusters PXDClustersToPXDDigits PXDClustersToPXDTrueHits PXDDigits PXDTrueHits'
46
assert
0 == os.system(
'b2file-check -n 5 -s 10 0.5 '
+ rootfile +
' '
+ allbranches)
47
assert
0 == os.system(
'b2file-check --json -n 5 -s 10 0.5 '
+ rootfile +
' '
+ allbranches)
48
49
assert
0 != os.system(
'b2file-check -n 5 -s 10 0.5 '
+ rootfile +
' NotThere'
)
50
assert
0 != os.system(
'b2file-check -n 5 -s 10 0.5 '
+ rootfile +
' EventMetaData NotThere'
)
51
assert
0 != os.system(
'b2file-check -n 5 -s 10 0.5 '
+ rootfile +
' NotThere EventMetaData'
)
52
assert
0 != os.system(
'b2file-check -n 5 -s 10 0.5 '
+ rootfile +
' FileMetaData'
)
framework
tests
test_check_basf2_file.py
Generated on Fri Nov 8 2024 02:38:05 for Belle II Software by
1.9.6