tardisbase.testing.regression_data.regression_data module

class tardisbase.testing.regression_data.regression_data.PlotDataHDF(*args, **kwargs)[source]

Bases: HDFWriterMixin

A class that writes plot data to HDF5 format using the HDFWriterMixin.

Initializes PlotDataHDF with arbitrary keyword arguments, storing them as attributes and adding their names to hdf_properties.

Parameters:

**kwargs: Arbitrary keyword arguments representing properties to save.

class tardisbase.testing.regression_data.regression_data.PytestWritingPlugin[source]

Bases: object

pytest_report_teststatus(report, config)[source]

Custom pytest hook to report test status for regression data writing.

This hook is called by pytest to determine the test outcome status and provides custom reporting for tests that have written regression data.

Parameters:
  • report (pytest.TestReport) – The test report object containing information about the test execution, including any custom attributes set during the test run.

  • config (pytest.Config) – The pytest configuration object containing command-line options and configuration settings.

Returns:

If the test report has a ‘written’ attribute that is True, returns a tuple containing: - outcome: “regression data written” (test outcome description) - letter: “W” (single letter representation) - word: “WRITTEN” (word representation for verbose output)

Returns None if the condition is not met, allowing other hooks or default behavior to determine the test status.

Return type:

tuple of (str, str, str) or None

Notes

This hook is typically used in conjunction with pytest plugins that handle regression testing data, allowing tests to be marked as having successfully written reference data rather than just passing or failing.

pytest_runtest_makereport(item, call)[source]

Custom pytest hook to handle test report generation for regression data writing.

This hook intercepts test execution and creates a custom test report when a TestWrite exception is encountered, marking the test as “written” rather than failed.

Parameters:
  • item (pytest.Item) – The test item being executed.

  • call (pytest.CallInfo) – Information about the test call, including any exception information.

Returns:

Returns a custom TestReport with outcome “written” if a TestWrite exception was raised, otherwise returns None to allow default report generation.

Return type:

TestReport or None

Notes

This hook is specifically designed for regression testing workflows where tests may write reference data instead of comparing against it. When a TestWrite exception is raised, it indicates successful data writing rather than a test failure.

class tardisbase.testing.regression_data.regression_data.RegressionData(request)[source]

Bases: object

property absolute_regression_data_dir
property fname_prefix
property fpath
property module_name
property relative_regression_data_dir
sync_dataframe(data, key='data')[source]

Synchronizes the dataframe with the regression data.

Parameters:
  • data (DataFrame) – The dataframe to be synchronized.

  • key (str, optional) – The key to use for storing the dataframe in the regression data file. Defaults to “data”.

Returns:

The synchronized dataframe if enable_generate_reference is False, otherwise None.

Return type:

DataFrame or None

sync_hdf_store(tardis_module, update_fname=True)[source]

Synchronizes the HDF store with the regression data.

Parameters:
  • tardis_module (object) – The module to be synchronized.

  • update_fname (bool, optional) – Whether to update the file name. Defaults to True.

Returns:

The synchronized HDF store if enable_generate_reference is False, otherwise None.

Return type:

HDFStore or None

sync_ndarray(data)[source]

Synchronizes the ndarray with the regression data.

Parameters:

data (ndarray) – The ndarray to be synchronized.

Returns:

The synchronized ndarray if enable_generate_reference is False, otherwise None.

Return type:

ndarray or None

sync_str(data)[source]

Synchronizes the string with the regression data.

Parameters:

data (str) – The string to be synchronized.

Returns:

The synchronized string if enable_generate_reference is False, otherwise None.

Return type:

str or None

property test_name
exception tardisbase.testing.regression_data.regression_data.TestWrite(msg: str | None = None, pytrace: bool = True)[source]

Bases: OutcomeException

tardisbase.testing.regression_data.regression_data.regression_data(request)[source]
tardisbase.testing.regression_data.regression_data.write_status()[source]