parametrize_from_file.add_loader

parametrize_from_file.add_loader(suffix, loader)

Read test parameters from a custom file type.

Parameters:
  • 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 (collections.abc.Callable) –

    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.

Note

Each file is only loaded once per pytest session.