Skip to content

Commit effd281

Browse files
committed
TST Adds more interesting test
1 parent c8e9a68 commit effd281

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

sklearn/utils/tests/test_metaestimators.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,14 @@ def test_if_delegate_has_method():
9494
class AvailableParameterEstimator:
9595
"""This estimator's `available` parameter toggles the presence of a method"""
9696

97-
def __init__(self, available=True):
97+
def __init__(self, available=True, return_value=1):
9898
self.available = available
99+
self.return_value = return_value
99100

100101
@available_if(lambda est: est.available)
101102
def available_func(self):
102103
"""This is a mock available_if function"""
103-
pass
104+
return self.return_value
104105

105106

106107
def test_available_if_docstring():
@@ -164,5 +165,8 @@ def test_available_if_methods_can_be_pickled():
164165
165166
Non-regression test for #21344.
166167
"""
167-
est = AvailableParameterEstimator(available=True)
168-
pickle.dumps(est.available_func)
168+
return_value = 10
169+
est = AvailableParameterEstimator(available=True, return_value=return_value)
170+
pickled_bytes = pickle.dumps(est.available_func)
171+
unpickled_func = pickle.loads(pickled_bytes)
172+
assert unpickled_func() == return_value

0 commit comments

Comments
 (0)