Skip to content

Commit 5ce2cb4

Browse files
committed
ENH: Validate type for list or tuple exclusively
1 parent ec6f9dc commit 5ce2cb4

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

scipy_doctest/impl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ def check_output(self, want, got, optionflags):
324324
return self.check_output(want_again, got_again, optionflags)
325325

326326
# Validate data type if list or tuple
327-
is_list_or_tuple = (isinstance(a_want, (list, tuple)) or
327+
is_list_or_tuple = (isinstance(a_want, (list, tuple)) and
328328
isinstance(a_got, (list, tuple)))
329329
if is_list_or_tuple and type(a_want) is not type(a_got):
330330
return False

scipy_doctest/tests/failure_cases.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__all__ = ['func9', 'func10', 'iterable_length_1', 'iterable_length_2',
2-
'different_iteralbes_1', 'different_iteralbes_2']
2+
'tuple_and_list_1', 'tuple_and_list_2']
33

44

55
def func9():
@@ -33,16 +33,15 @@ def iterable_length_2():
3333
"""
3434

3535

36-
def different_iteralbes_1():
36+
def tuple_and_list_1():
3737
"""
3838
>>> [0, 1, 2]
3939
(0, 1, 2)
4040
"""
4141

4242

43-
def different_iteralbes_2():
43+
def tuple_and_list_2():
4444
"""
45-
>>> import numpy as np
46-
>>> np.array([0, 1, 2])
45+
>>> (0, 1, 2)
4746
[0, 1, 2]
4847
"""

scipy_doctest/tests/module_cases.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,19 @@ def test_cmplx_nan():
190190
>>> 1j*np.complex128(np.nan)
191191
np.complex128(nan+nanj)
192192
"""
193+
194+
195+
def array_and_list_1():
196+
"""
197+
>>> import numpy as np
198+
>>> np.array([1, 2, 3])
199+
[1, 2, 3]
200+
"""
201+
202+
203+
def array_and_list_2():
204+
"""
205+
>>> import numpy as np
206+
>>> [1, 2, 3]
207+
array([1, 2, 3])
208+
"""

scipy_doctest/tests/test_testmod.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ def test_wrong_lengths():
108108
assert res.failed == 2
109109

110110

111-
def test_different_iterables():
111+
def test_tuple_and_list():
112112
config = DTConfig()
113113
res, _ = _testmod(failure_cases,
114-
strategy=[failure_cases.different_iteralbes_1,
115-
failure_cases.different_iteralbes_2],
114+
strategy=[failure_cases.tuple_and_list_1,
115+
failure_cases.tuple_and_list_2],
116116
config=config)
117117
assert res.failed == 2
118118

0 commit comments

Comments
 (0)