16from basf2
import find_file
17from b2test_utils
import clean_working_directory, configure_logging_for_tests
18from b2test_utils_analysis
import scanTTree
22 """Test to run all B2A9XX tutorials. Will fail if no tutorial directory is found."""
25 broken_tutorials = [
'B2A910-ApplyKsSelector.py']
27 do_not_overwrite = [
'B2A911-CreateTrainData.py']
29 @unittest.skipIf(not os.getenv('BELLE2_EXAMPLES_DATA_DIR'),
30 "$BELLE2_EXAMPLES_DATA_DIR not found.")
31 @unittest.skipIf(not os.getenv('BELLE2_VALIDATION_DATA_DIR'),
32 "$BELLE2_VALIDATION_DATA_DIR not found.")
35 Test supported tutorials.
37 configure_logging_for_tests()
38 all_tutorials = sorted(glob.glob(find_file('analysis/examples/tutorials/') +
"/B2A9*.py"))
39 for tutorial
in all_tutorials:
40 filename = os.path.basename(tutorial)
42 with self.subTest(msg=filename):
43 outputfilename = filename.replace(
'.py',
'.root')
45 result = subprocess.run([
'basf2',
'-n100', tutorial,
'-o', outputfilename],
46 stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
48 result = subprocess.run([
'basf2',
'-n100', tutorial],
49 stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
51 if result.returncode != 0:
55 sys.stdout.buffer.write(result.stdout)
56 self.assertEqual(result.returncode, 0)
58 if os.path.exists(outputfilename):
59 scanTTree(outputfilename)
62if __name__ ==
'__main__':
63 with clean_working_directory():
list do_not_overwrite
list of the tutorials whose output file name cannot be overwritten
list broken_tutorials
list of the broken tutorials (to be removed when they are individually fixed)