Belle II Software light-2406-ragdoll
ExamplesTest Class Reference
Inheritance diagram for ExamplesTest:
Collaboration diagram for ExamplesTest:

Protected Member Functions

def _test_examples_dir (self, path_to_glob, broken=None)
 

Detailed Description

Test to run all example scripts.

Definition at line 19 of file b2test_utils_analysis.py.

Member Function Documentation

◆ _test_examples_dir()

def _test_examples_dir (   self,
  path_to_glob,
  broken = None 
)
protected
Internal function to test a directory full of example scripts with an optional list of broken scripts to be skipped.

Parameters:
    path_to_glob (str): the path to search for scripts
    broken (list(str)): (optional) scripts that are known to be broken and can be skipped

Definition at line 26 of file b2test_utils_analysis.py.

26 def _test_examples_dir(self, path_to_glob, broken=None):
27 """
28 Internal function to test a directory full of example scripts with an optional list of broken scripts to be skipped.
29
30 Parameters:
31 path_to_glob (str): the path to search for scripts
32 broken (list(str)): (optional) scripts that are known to be broken and can be skipped
33 """
34 if broken is None:
35 broken = []
36 all_egs = sorted(glob.glob(find_file(path_to_glob) + "/*.py"))
37 for eg in all_egs:
38 filename = os.path.basename(eg)
39 if filename not in broken:
40 with self.subTest(msg=filename):
41 result = subprocess.run(['basf2', '-n1', eg], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
42 if result.returncode != 0:
43 # failure running example so let's print the output
44 # on stderr so it's not split from output of unittest
45 # done like this since we don't want to decode/encode utf8
46 sys.stdout.buffer.write(result.stdout)
47 self.assertEqual(result.returncode, 0)
48
49

The documentation for this class was generated from the following file: