Skip to content

Commit

Permalink
test(helper): add tests in helper
Browse files Browse the repository at this point in the history
  • Loading branch information
MarieSacksick committed Mar 7, 2025
1 parent f66ea36 commit f81cc0c
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion skore/tests/unit/sklearn/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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"
)

0 comments on commit f81cc0c

Please sign in to comment.