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