bundle.testing.tools.utils

Attributes

Functions

ensure_path(→ pathlib.Path)

Ensures existence of a path's directories. For file paths, creates missing parent directories.

class_instance_name(class_instance)

retrieves_tests_paths(→ tuple[pathlib.Path, ...)

Generate and ensure paths for reference, temporary, failed tests, and their logs based on

Module Contents

bundle.testing.tools.utils.logger
bundle.testing.tools.utils.ensure_path(path: pathlib.Path | str) pathlib.Path[source]

Ensures existence of a path’s directories. For file paths, creates missing parent directories. For directory paths, creates the directory if missing. Logs creation actions.

Parameters:

path (Path) – Target file or directory path.

Returns:

Verified path

Return type:

Path

bundle.testing.tools.utils.class_instance_name(class_instance: object)[source]
bundle.testing.tools.utils.retrieves_tests_paths(category: str, ref_dir: str | pathlib.Path, tmp_dir: str | pathlib.Path, class_instance: object, suffix: str, extension: str = 'json') tuple[pathlib.Path, pathlib.Path, pathlib.Path, pathlib.Path][source]

Generate and ensure paths for reference, temporary, failed tests, and their logs based on the test category, directory references, test instance, and file details.

Parameters:
  • category (str) – A ‘/’ separated string defining the test category hierarchy.

  • ref_dir (str | Path) – The base directory for reference files.

  • tmp_dir (str | Path) – The base directory for temporary test files.

  • class_instance (object) – The test class instance to include in the filename.

  • suffix (str) – Suffix to append to the base filename, typically a test identifier.

  • extension (str, optional) – File extension for the test files. Defaults to “json”.

Returns:

A tuple containing paths for reference, temporary, failed test files, and failed test logs.

Return type:

tuple[Path, Path, Path, Path]