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

1""" 

2Test the class_inspect module. 

3 

4This test file is in nilearn/tests because Nosetest, 

5which we historically used, 

6ignores modules whose name starts with an underscore. 

7""" 

8 

9from sklearn.base import BaseEstimator 

10 

11from nilearn._utils import class_inspect 

12 

13############################################################################## 

14# Helpers for the tests 

15 

16 

17class A(BaseEstimator): 

18 def __init__(self, a=1): 

19 self.a = a 

20 

21 

22class B(A): 

23 def __init__(self, a=1, b=2): 

24 self.a = a 

25 self.b = b 

26 

27 

28############################################################################## 

29# The tests themselves 

30 

31 

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 == {}