Coverage for nilearn/_utils/tests/test_class_inspect.py: 0%
15 statements
« prev ^ index » next coverage.py v7.9.1, created at 2025-06-20 10:58 +0200
« prev ^ index » next coverage.py v7.9.1, created at 2025-06-20 10:58 +0200
1"""
2Test the class_inspect module.
4This test file is in nilearn/tests because Nosetest,
5which we historically used,
6ignores modules whose name starts with an underscore.
7"""
9from sklearn.base import BaseEstimator
11from nilearn._utils import class_inspect
13##############################################################################
14# Helpers for the tests
17class A(BaseEstimator):
18 def __init__(self, a=1):
19 self.a = a
22class B(A):
23 def __init__(self, a=1, b=2):
24 self.a = a
25 self.b = b
28##############################################################################
29# The tests themselves
32def test_get_params():
33 b = B()
34 params_a_in_b = class_inspect.get_params(A, b)
35 assert params_a_in_b == {"a": 1}
36 params_a_in_b = class_inspect.get_params(A, b, ignore=["a"])
37 assert params_a_in_b == {}