Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def collect(self):
"""Yield test cases from a AnyScript test file."""
# Collect define statements from the header
strheader = _read_header(self.fspath.strpath)
header = _parse_header(strheader)
def_list = _format_switches(header.pop("define", None))
def_list = [
replace_bm_constants(d, pytest.anytest.bm_constants_map) for d in def_list
]
path_list = _format_switches(header.pop("path", None))
combinations = itertools.product(def_list, path_list)
# Run though the defines an create a test case for each
for i, (defs, paths) in enumerate(combinations):
if isinstance(defs, dict) and isinstance(paths, dict):
if PYTEST_PRE_54:
yield AnyTestItem(
name=self.fspath.basename,
id=i,
parent=self,
defs=defs,
paths=paths,
**header,
)
else:
yield AnyTestItem.from_parent(
name=self.fspath.basename,
id=i,
parent=self,
defs=defs,
paths=paths,
**header,
)
path_list = _format_switches(header.pop("path", None))
combinations = itertools.product(def_list, path_list)
# Run though the defines an create a test case for each
for i, (defs, paths) in enumerate(combinations):
if isinstance(defs, dict) and isinstance(paths, dict):
if PYTEST_PRE_54:
yield AnyTestItem(
name=self.fspath.basename,
id=i,
parent=self,
defs=defs,
paths=paths,
**header,
)
else:
yield AnyTestItem.from_parent(
name=self.fspath.basename,
id=i,
parent=self,
defs=defs,
paths=paths,
**header,
)
else:
raise ValueError("Malformed input: ", header)