tardisbase.testing.regression_comparison.util module¶
- tardisbase.testing.regression_comparison.util.color_print(text, color)[source]¶
Print text to the console with ANSI color formatting.
This function provides colored console output using ANSI escape codes, making it easier to distinguish different types of messages in terminal output. The text is automatically reset to default color after printing.
- Parameters:
Notes
The function uses ANSI escape codes for coloring: - Red: 033[91m - Green: 033[92m - Yellow: 033[93m - Blue: 033[94m - Reset: 033[0m
- tardisbase.testing.regression_comparison.util.get_last_n_commits(n=2, repo_path=None)[source]¶
Get the last n commits from a git repository using GitPython.
- Parameters:
- Returns:
List of commit hashes (strings)
- Return type:
- Raises:
ValueError – If repository not found or git operations fail
- tardisbase.testing.regression_comparison.util.get_relative_path(path, base)[source]¶
Calculate the relative path from a base directory to a target path.
This function computes the relative path representation of a target path with respect to a base directory, returning the result as a string.
- Parameters:
- Returns:
The relative path from base to path as a string.
- Return type:
- Raises:
ValueError – If the path is not relative to the base directory (i.e., they don’t share a common root or the path is outside the base directory tree).
Notes
This function uses pathlib.Path.relative_to() internally, which requires that the target path be within the base directory hierarchy. If the paths are on different drives (Windows) or don’t share a common ancestor, a ValueError will be raised.