8000 Add a test case for the case where __getstate__ hasn't been overwritten · scikit-learn/scikit-learn@9c857f6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9c857f6

Browse files
committed
Add a test case for the case where __getstate__ hasn't been overwritten
in a second class
1 parent 0f245d4 commit 9c857f6

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

sklearn/tests/test_base.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,3 +386,16 @@ def test_pickling_constraints_work_in_multiple_inheritance_setting():
386386
estimator_restored = pickle.loads(serialized)
387387
assert estimator_restored.b == 5
388388
assert estimator_restored._cache is None
389+
390+
391+
class SingleInheritanceEstimator(BaseEstimator):
392+
def __init__(self, b=5):
393+
self.b = b
394+
395+
396+
def test_pickling_uses_object_dictionary_when_getstate_not_present():
397+
estimator = MultiInheritanceEstimator()
398+
399+
serialized = pickle.dumps(estimator, protocol=2)
400+
estimator_restored = pickle.loads(serialized)
401+
assert estimator_restored.b == 5

0 commit comments

Comments
 (0)
0