1
1
import pytest
2
2
3
+ import numpy as np
4
+
3
5
from . import finder_cases
4
6
from ..util import get_all_list , get_public_objects
5
7
from ..impl import DTFinder , DTConfig
6
8
from ..frontend import find_doctests
7
9
10
+
8
11
def test_get_all_list ():
9
12
items , depr , other = get_all_list (finder_cases )
10
13
assert sorted (items ) == ['Klass' , 'func' ]
@@ -111,6 +114,7 @@ def test_get_doctests_strategy_api(self):
111
114
# - *private* stuff, which is not in `__all__`
112
115
wanted_names = ['Klass' , 'Klass.meth' ]
113
116
wanted_names = [base ] + [base + '.' + n for n in wanted_names ]
117
+ wanted_names += [f'{ base } .Klass.__weakref__' ]
114
118
115
119
assert sorted (names ) == sorted (wanted_names )
116
120
@@ -129,6 +133,7 @@ def test_get_doctests_strategy_list(self):
129
133
# - the 'base' module (via the strategy=<list>)
130
134
wanted_names = ['Klass' , 'Klass.meth' ]
131
135
wanted_names = [base + '.' + n for n in wanted_names ]
136
+ wanted_names += [f'{ base } .Klass.__weakref__' ]
132
137
133
138
assert sorted (names ) == sorted (wanted_names )
134
139
@@ -139,7 +144,8 @@ def test_explicit_object_list():
139
144
140
145
base = 'scipy_doctest.tests.finder_cases'
141
146
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__' ])
143
149
144
150
145
151
def test_explicit_object_list_with_module ():
@@ -151,7 +157,8 @@ def test_explicit_object_list_with_module():
151
157
152
158
base = 'scipy_doctest.tests.finder_cases'
153
159
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__' ])
155
162
156
163
157
164
def test_find_doctests_api ():
@@ -161,10 +168,18 @@ def test_find_doctests_api():
161
168
base = 'scipy_doctest.tests.finder_cases'
162
169
assert ([test .name for test in tests ] ==
163
170
[base + '.func' , base + '.Klass' , base + '.Klass.meth' ,
164
- base + '.Klass.meth_2' , base ])
171
+ base + '.Klass.meth_2' , base + '.Klass.__weakref__' , base ])
165
172
166
173
167
174
def test_dtfinder_config ():
168
175
config = DTConfig ()
169
176
finder = DTFinder (config = config )
170
177
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