17 from basf2
import find_file
18 from b2test_utils
import clean_working_directory, configure_logging_for_tests
19 from b2test_utils_analysis
import scanTTree
23 """Test to run all B2A9XX tutorials. Will fail if no tutorial directory is found."""
28 do_not_overwrite = [
'B2A911-CreateTrainData.py']
30 @unittest.skipIf(not os.getenv('BELLE2_EXAMPLES_DATA_DIR'),
31 "$BELLE2_EXAMPLES_DATA_DIR not found.")
32 @unittest.skipIf(not os.getenv('BELLE2_VALIDATION_DATA_DIR'),
33 "$BELLE2_VALIDATION_DATA_DIR not found.")
36 Test supported tutorials.
38 configure_logging_for_tests()
39 all_tutorials = sorted(glob.glob(find_file(
'analysis/examples/tutorials/') +
"/B2A9*.py"))
40 for tutorial
in all_tutorials:
41 filename = os.path.basename(tutorial)
43 with self.subTest(msg=filename):
44 outputfilename = filename.replace(
'.py',
'.root')
46 result = subprocess.run([
'basf2',
'-n100', tutorial,
'-o', outputfilename],
47 stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
49 result = subprocess.run([
'basf2',
'-n100', tutorial],
50 stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
52 if result.returncode != 0:
56 sys.stdout.buffer.write(result.stdout)
57 self.assertEqual(result.returncode, 0)
59 if os.path.exists(outputfilename):
60 scanTTree(outputfilename)
63 if __name__ ==
'__main__':
64 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)