9 from basf2
import find_file
10 from b2test_utils
import clean_working_directory
14 """Test to run all tutorials. Will fail if no tutorial directory is found."""
17 broken_tutorials = [
'B2A702-ContinuumSuppression_MVATrain.py',
18 'B2A703-ContinuumSuppression_MVAExpert.py',
19 'B2A503-ReadDecayHash.py',
22 @unittest.skipIf(
not os.getenv(
'BELLE2_EXAMPLES_DATA_DIR'),
23 "$BELLE2_EXAMPLES_DATA_DIR not found.")
24 @unittest.skipIf(
not os.getenv(
'BELLE2_VALIDATION_DATA_DIR'),
25 "$BELLE2_VALIDATION_DATA_DIR not found.")
28 Test supported tutorials.
30 all_tutorials = sorted(glob.glob(find_file(
'analysis/examples/tutorials/') +
"*.py"))
31 for tutorial
in all_tutorials:
32 filename = os.path.basename(tutorial)
34 with self.subTest(msg=filename):
35 result = subprocess.run([
'basf2',
'-n1', tutorial], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
36 if result.returncode != 0:
40 sys.stdout.buffer.write(result.stdout)
41 self.assertEqual(result.returncode, 0)
44 if __name__ ==
'__main__':
45 with clean_working_directory():