Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
MarieSacksick committed Mar 7, 2025
1 parent f81cc0c commit b198cdb
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions skore/tests/unit/sklearn/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from sklearn.datasets import make_classification
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
from skore.sklearn._base import _BaseAccessor, _get_cached_response_values
from skore.sklearn._base import _BaseAccessor, _BaseReport, _get_cached_response_values


class MockClassifier(ClassifierMixin, BaseEstimator):
Expand Down Expand Up @@ -176,15 +176,16 @@ 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.
class MockReport(_BaseReport):
"""Mock a report with the minimal required attributes.
Attributes
----------
no_private : dummy object
The text to catch.
"""

Attributes
----------
no_private : dummy object
The text to catch.
"""
def __init__(self, estimator, X_train=None, y_train=None, X_test=None, y_test=None):
self._estimator = estimator
self._X_train = X_train
self._y_train = y_train
Expand Down Expand Up @@ -316,12 +317,18 @@ def test_base_accessor_get_X_y_and_data_source_hash(data_source):


def test_base_accessor_get_attributes_description():
_get_attributes_for_help = MockAccessor._get_attributes_for_help
X, y = make_classification(n_samples=10, n_classes=2, random_state=42)
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)
estimator = LogisticRegression()
report = MockReport(
estimator, X_train=X_train, y_train=y_train, X_test=X_test, y_test=y_test
)

attributes = report._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 len(attributes) == 7
assert report._get_attribute_description("no_private") == "The text to catch"
assert (
MockAccessor._get_attribute_description("attr_without_description")
report._get_attribute_description("attr_without_description")
== "No description available"
)

0 comments on commit b198cdb

Please sign in to comment.