Belle II Software  release-05-02-19
SteeringFileTest Class Reference
Inheritance diagram for SteeringFileTest:
Collaboration diagram for SteeringFileTest:

Public Member Functions

def test_lessons_1_to_5 (self)
 

Private Member Functions

def _test_examples_dir (self, str path_to_glob, Optional[List[str]] broken=None, Optional[List[str]] additional_arguments=None, Optional[List[str]] expensive_tests=None, change_working_directory=True)
 

Detailed Description

Test steering files 

Definition at line 31 of file steering_files.py.

Member Function Documentation

◆ _test_examples_dir()

def _test_examples_dir (   self,
str  path_to_glob,
Optional[List[str]]   broken = None,
Optional[List[str]]   additional_arguments = None,
Optional[List[str]]   expensive_tests = None,
  change_working_directory = True 
)
private
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 a directory to search for python
scripts (must end in .py)
    broken (list(str)): (optional) names of scripts that are known to
be broken and can be skipped
    expensive_tests (list(str)): (optional) names of scripts that take
longer and should e.g. not run on bamboo
    additional_arguments (list(str)): (optional) additional arguments
for basf2 to be passed when testing the scripts
    change_working_directory: Change to path_to_glob for execution

Definition at line 34 of file steering_files.py.

34  def _test_examples_dir(
35  self,
36  path_to_glob: str,
37  broken: Optional[List[str]] = None,
38  additional_arguments: Optional[List[str]] = None,
39  expensive_tests: Optional[List[str]] = None,
40  change_working_directory=True,
41  ):
42  """
43  Internal function to test a directory full of example scripts with an
44  optional list of broken scripts to be skipped.
45 
46  Parameters:
47  path_to_glob (str): the path to a directory to search for python
48  scripts (must end in .py)
49  broken (list(str)): (optional) names of scripts that are known to
50  be broken and can be skipped
51  expensive_tests (list(str)): (optional) names of scripts that take
52  longer and should e.g. not run on bamboo
53  additional_arguments (list(str)): (optional) additional arguments
54  for basf2 to be passed when testing the scripts
55  change_working_directory: Change to path_to_glob for execution
56  """
57  if additional_arguments is None:
58  additional_arguments = []
59  if broken is None:
60  broken = []
61  if expensive_tests is None:
62  expensive_tests = []
63  working_dir = find_file(path_to_glob)
64  all_egs = sorted(glob.glob(working_dir + "/*.py"))
65  for eg in all_egs:
66  filename = os.path.basename(eg)
67  if filename in broken:
68  continue
69  if skip_expensive_tests and filename in expensive_tests:
70  continue
71  with self.subTest(msg=filename):
72  result = subprocess.run(
73  ["basf2", "-n1", eg, *additional_arguments],
74  stdout=subprocess.PIPE,
75  stderr=subprocess.STDOUT,
76  cwd=working_dir,
77  )
78  if result.returncode != 0:
79  # failure running example so let's print the output
80  # on stderr so it's not split from output of unittest
81  # done like this since we don't want to decode/encode utf8
82  sys.stdout.buffer.write(result.stdout)
83  self.assertEqual(result.returncode, 0)
84 

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