How to use the anypytools.pytest_plugin.AnyTestItem function in anypytools

To help you get started, we’ve selected a few anypytools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AnyBody-Research-Group / AnyPyTools / anypytools / pytest_plugin.py View on Github external
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,
                    )
github AnyBody-Research-Group / AnyPyTools / anypytools / pytest_plugin.py View on Github external
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)