Belle II Software
release-08-01-10
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
# sadly, our input file doesn't have mcEvents stored (==0)
33
assert
0 == os.system(
'b2file-check --mcevents 0 '
+ rootfile)
34
assert
0 != os.system(
'b2file-check --mcevents 123 '
+ rootfile)
35
36
assert
0 == os.system(
'b2file-check -n 5 -s 12.4 1 '
+ rootfile)
37
assert
0 == os.system(
'b2file-check -n 5 -s 12.4 0.05 '
+ rootfile)
38
assert
0 != os.system(
'b2file-check -n 5 -s 12.4 0 '
+ rootfile)
39
40
assert
0 == os.system(
'b2file-check -n 5 -s 10 1 '
+ rootfile)
41
assert
0 == os.system(
'b2file-check -n 5 -s 10 0.5 '
+ rootfile)
42
assert
0 != os.system(
'b2file-check -n 5 -s 10 0.2 '
+ rootfile)
43
assert
0 != os.system(
'b2file-check -n 5 -s 10 0.05 '
+ rootfile)
44
45
assert
0 == os.system(
'b2file-check -n 5 -s 10 0.5 '
+ rootfile +
' EventMetaData'
)
46
allbranches =
'EventMetaData PXDClusters PXDClustersToPXDDigits PXDClustersToPXDTrueHits PXDDigits PXDTrueHits'
47
assert
0 == os.system(
'b2file-check -n 5 -s 10 0.5 '
+ rootfile +
' '
+ allbranches)
48
assert
0 == os.system(
'b2file-check --json -n 5 -s 10 0.5 '
+ rootfile +
' '
+ allbranches)
49
50
assert
0 != os.system(
'b2file-check -n 5 -s 10 0.5 '
+ rootfile +
' NotThere'
)
51
assert
0 != os.system(
'b2file-check -n 5 -s 10 0.5 '
+ rootfile +
' EventMetaData NotThere'
)
52
assert
0 != os.system(
'b2file-check -n 5 -s 10 0.5 '
+ rootfile +
' NotThere EventMetaData'
)
53
assert
0 != os.system(
'b2file-check -n 5 -s 10 0.5 '
+ rootfile +
' FileMetaData'
)
framework
tests
test_check_basf2_file.py
Generated on Mon Sep 23 2024 14:02:32 for Belle II Software by
1.9.1