9 from basf2
import find_file
10 from b2test_utils
import clean_working_directory, skip_test_if_light
14 """Test to run all example scripts."""
16 @unittest.skipIf(
not os.getenv(
'BELLE2_EXAMPLES_DATA_DIR'),
17 "$BELLE2_EXAMPLES_DATA_DIR not found.")
18 @unittest.skipIf(
not os.getenv(
'BELLE2_VALIDATION_DATA_DIR'),
19 "$BELLE2_VALIDATION_DATA_DIR not found.")
22 Internal function to test a directory full of example scripts with an optional list of broken scripts to be skipped.
25 path_to_glob (str): the path to search for scripts
26 broken (list(str)): (optional) scripts that are known to be broken and can be skipped
28 all_egs = sorted(glob.glob(find_file(path_to_glob) +
"*.py"))
30 filename = os.path.basename(eg)
31 if filename
not in broken:
32 with self.subTest(msg=filename):
33 result = subprocess.run([
'basf2',
'-n1', eg], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
34 if result.returncode != 0:
38 sys.stdout.buffer.write(result.stdout)
39 self.assertEqual(result.returncode, 0)
43 Test supported calibration examples.
45 skip_test_if_light(self)
48 broken_cal_egs = [
'B2CAL901-cDSTECLTRG.py'
55 Test supported FEI examples.
62 Test supported fitting examples.
69 Test supported mva examples.
72 broken_mva_egs = [
'B2A711-DeepContinuumSuppression_Input.py',
73 'B2A713-DeepContinuumSuppression_MVAExpert.py',
74 'B2A712-DeepContinuumSuppression_MVATrain.py',
75 'B2A714-DeepContinuumSuppression_MVAModel.py'
82 Test supported reconstruction examples.
89 Test supported simulation examples.
91 skip_test_if_light(self)
94 broken_sim_egs = [
'B2A104-SimulateAndReconstruct-withBeamBkg.py'
101 Test supported tagging examples.
108 Test supported variable manager examples.
115 Test supported PostMdstIdentification examples.
121 if __name__ ==
'__main__':
122 with clean_working_directory():