parametrize_from_file.add_loader(suffix, loader)

Read test parameters from a custom file type.

  • suffix (str) – The file suffix to associate with the given loader. This should include a leading dot, e.g. '.yml'. It is possible to overwrite the default suffixes with this function.

  • loader ( –

    A function that will be used to load parameters from a file. It should have the following signature:

    def loader(path: pathlib.Path) -> Dict[str, List[Dict[str, Any]]]

    In other words, it should accept a path and return the top-level data structure expected by @parametrize_from_file.


Each file is only loaded once per pytest session.