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 B2A7XX tutorials. Will fail if no tutorial directory is found."""
27 @unittest.skipIf(not os.getenv('BELLE2_EXAMPLES_DATA_DIR'),
28 "$BELLE2_EXAMPLES_DATA_DIR not found.")
29 @unittest.skipIf(not os.getenv('BELLE2_VALIDATION_DATA_DIR'),
30 "$BELLE2_VALIDATION_DATA_DIR not found.")
33 Test supported tutorials.
35 configure_logging_for_tests()
36 all_tutorials = sorted(glob.glob(find_file('analysis/examples/tutorials/') +
"/B2A7*.py"))
37 for tutorial
in all_tutorials:
38 filename = os.path.basename(tutorial)
40 with self.subTest(msg=filename):
41 outputfilename = filename.replace(
'.py',
'.root')
42 result = subprocess.run([
'basf2',
'-n100', tutorial,
'-o', outputfilename],
43 stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
44 if result.returncode != 0:
48 sys.stdout.buffer.write(result.stdout)
49 self.assertEqual(result.returncode, 0)
51 if os.path.exists(outputfilename):
52 scanTTree(outputfilename)
55if __name__ ==
'__main__':
56 with clean_working_directory():
list broken_tutorials
list of the broken tutorials (to be removed when they are individually fixed)