The Gaudi Framework  v38r3 (c3fc9673)
collect_for_ctest Namespace Reference

Functions

def pytest_addoption (parser, pluginmanager)
 
def pytest_collection_modifyitems (session, config, items)
 
def pytest_collection_finish (session)
 

Variables

 TEST_DESC_TEMPLATE
 

Function Documentation

◆ pytest_addoption()

def collect_for_ctest.pytest_addoption (   parser,
  pluginmanager 
)

Definition at line 23 of file collect_for_ctest.py.

23 def pytest_addoption(parser, pluginmanager):
24  parser.addoption(
25  "--ctest-output-file",
26  type=argparse.FileType("w"),
27  help="name of the file to write to communicate to ctest the discovered tests",
28  )
29  parser.addoption(
30  "--ctest-pytest-command",
31  default="pytest",
32  help="how pytest has to be invoked (e.g. using wrapper commands)",
33  )
34  parser.addoption(
35  "--ctest-pytest-root-dir",
36  default=Path.cwd(),
37  help="root directory to compute test names",
38  )
39  parser.addoption(
40  "--ctest-prefix",
41  default="",
42  help="string to prefix to the generated test names",
43  )
44  parser.addoption(
45  "--ctest-label",
46  default=["pytest"],
47  action="append",
48  help="labels to attach to the test (the label pytest is always added)",
49  )
50  parser.addoption(
51  "--ctest-properties",
52  default=[],
53  action="append",
54  help="test properties to set for all discovered tests",
55  )
56 
57 

◆ pytest_collection_finish()

def collect_for_ctest.pytest_collection_finish (   session)

Definition at line 76 of file collect_for_ctest.py.

76 def pytest_collection_finish(session):
77  args = session.ctest_args
78  output = args.get("output_file")
79  if not output:
80  # nothing to do if no output file is specified
81  return
82 
83  properties = 'LABELS "{}" '.format(";".join(args["label"]))
84  properties += " ".join(args["properties"])
85 
86  for path in sorted(session.ctest_files):
87  name = (
88  args["prefix"] + os.path.relpath(path, args["pytest_root_dir"])
89  ).replace("/", ".")
90  if name.endswith(".py"):
91  name = name[:-3]
92  output.write(
93  TEST_DESC_TEMPLATE.format(
94  name=name,
95  path=path,
96  pytest_cmd=args["pytest_command"],
97  properties=properties,
98  )
99  )
100 
101  output.close()

◆ pytest_collection_modifyitems()

def collect_for_ctest.pytest_collection_modifyitems (   session,
  config,
  items 
)

Definition at line 58 of file collect_for_ctest.py.

58 def pytest_collection_modifyitems(session, config, items):
59  args = {
60  name[6:]: getattr(config.option, name)
61  for name in dir(config.option)
62  if name.startswith("ctest_")
63  }
64  session.ctest_args = args
65  session.ctest_files = set(
66  item.path if hasattr(item, "path") else Path(item.fspath) for item in items
67  )
68 
69 

Variable Documentation

◆ TEST_DESC_TEMPLATE

collect_for_ctest.TEST_DESC_TEMPLATE

Definition at line 70 of file collect_for_ctest.py.

ReadAndWriteWhiteBoard.Path
Path
Definition: ReadAndWriteWhiteBoard.py:58
collect_for_ctest.pytest_collection_finish
def pytest_collection_finish(session)
Definition: collect_for_ctest.py:76
collect_for_ctest.pytest_collection_modifyitems
def pytest_collection_modifyitems(session, config, items)
Definition: collect_for_ctest.py:58
format
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:119
collect_for_ctest.pytest_addoption
def pytest_addoption(parser, pluginmanager)
Definition: collect_for_ctest.py:23