From f81cc0ccb9d1964ba239f6c3700424c04138d849 Mon Sep 17 00:00:00 2001 From: Marie Date: Fri, 7 Mar 2025 08:50:52 +0100 Subject: [PATCH] test(helper): add tests in helper --- skore/tests/unit/sklearn/test_base.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/skore/tests/unit/sklearn/test_base.py b/skore/tests/unit/sklearn/test_base.py index c8ade906c..735278551 100644 --- a/skore/tests/unit/sklearn/test_base.py +++ b/skore/tests/unit/sklearn/test_base.py @@ -178,12 +178,20 @@ def test_get_cached_response_values_different_data_source_hash( class MockReport: def __init__(self, estimator, X_train=None, y_train=None, X_test=None, y_test=None): - """Mock a report with the minimal required attributes.""" + """Mock a report with the minimal required attributes. + + Attributes + ---------- + no_private : dummy object + The text to catch. + """ self._estimator = estimator self._X_train = X_train self._y_train = y_train self._X_test = X_test self._y_test = y_test + self.no_private = "no_private" + self.attr_without_description = "attr_without_description" @property def estimator_(self): @@ -305,3 +313,15 @@ def test_base_accessor_get_X_y_and_data_source_hash(data_source): assert X is X_test assert y is y_test assert data_source_hash == joblib.hash((X_test, y_test)) + + +def test_base_accessor_get_attributes_description(): + _get_attributes_for_help = MockAccessor._get_attributes_for_help + + # should only catch non private attributes + assert len(_get_attributes_for_help()) == 1 + assert MockAccessor._get_attribute_description("no_private") == "The text to catch" + assert ( + MockAccessor._get_attribute_description("attr_without_description") + == "No description available" + )