11import pytest
22
3+ import numpy as np
4+
35from . import finder_cases
46from ..util import get_all_list , get_public_objects
57from ..impl import DTFinder , DTConfig
68from ..frontend import find_doctests
79
10+
811def test_get_all_list ():
912 items , depr , other = get_all_list (finder_cases )
1013 assert sorted (items ) == ['Klass' , 'func' ]
@@ -111,6 +114,7 @@ def test_get_doctests_strategy_api(self):
111114 # - *private* stuff, which is not in `__all__`
112115 wanted_names = ['Klass' , 'Klass.meth' ]
113116 wanted_names = [base ] + [base + '.' + n for n in wanted_names ]
117+ wanted_names += [f'{ base } .Klass.__weakref__' ]
114118
115119 assert sorted (names ) == sorted (wanted_names )
116120
@@ -129,6 +133,7 @@ def test_get_doctests_strategy_list(self):
129133 # - the 'base' module (via the strategy=<list>)
130134 wanted_names = ['Klass' , 'Klass.meth' ]
131135 wanted_names = [base + '.' + n for n in wanted_names ]
136+ wanted_names += [f'{ base } .Klass.__weakref__' ]
132137
133138 assert sorted (names ) == sorted (wanted_names )
134139
@@ -139,7 +144,8 @@ def test_explicit_object_list():
139144
140145 base = 'scipy_doctest.tests.finder_cases'
141146 assert ([test .name for test in tests ] ==
142- [base + '.Klass' , base + '.Klass.meth' , base + '.Klass.meth_2' ])
147+ [f'{ base } .Klass' , f'{ base } .Klass.meth' , f'{ base } .Klass.meth_2' ,
148+ f'{ base } .Klass.__weakref__' ])
143149
144150
145151def test_explicit_object_list_with_module ():
@@ -151,7 +157,8 @@ def test_explicit_object_list_with_module():
151157
152158 base = 'scipy_doctest.tests.finder_cases'
153159 assert ([test .name for test in tests ] ==
154- [base , base + '.Klass' , base + '.Klass.meth' , base + '.Klass.meth_2' ])
160+ [base , f'{ base } .Klass' , f'{ base } .Klass.meth' , f'{ base } .Klass.meth_2' ,
161+ f'{ base } .Klass.__weakref__' ])
155162
156163
157164def test_find_doctests_api ():
@@ -161,10 +168,18 @@ def test_find_doctests_api():
161168 base = 'scipy_doctest.tests.finder_cases'
162169 assert ([test .name for test in tests ] ==
163170 [base + '.func' , base + '.Klass' , base + '.Klass.meth' ,
164- base + '.Klass.meth_2' , base ])
171+ base + '.Klass.meth_2' , base + '.Klass.__weakref__' , base ])
165172
166173
167174def test_dtfinder_config ():
168175 config = DTConfig ()
169176 finder = DTFinder (config = config )
170177 assert finder .config is config
178+
179+
180+ @pytest .mark .skipif (np .__version__ < '2' , reason = "XXX check if works on numpy 1.x" )
181+ def test_descriptors_get_collected ():
182+ tests = find_doctests (np , strategy = [np .dtype ])
183+ names = [test .name for test in tests ]
184+ assert 'numpy.dtype.kind' in names # was previously missing
185+
0 commit comments