Skip to content

Commit 0bfbd1f

Browse files
committed
Fix overflow test to work on numpy 1.5
1 parent 332f542 commit 0bfbd1f

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎astropy/io/ascii/tests/test_read.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,26 @@
1111
from ... import ascii as asciitable # TODO: delete this line, use ascii.*
1212
from ... import ascii
1313
from ....table import Table
14+
from distutils import version
1415

1516
from .common import (raises, assert_equal, assert_almost_equal,
1617
assert_true, setup_function, teardown_function)
1718
from ....tests.helper import pytest
1819

20+
_NUMPY_VERSION = version.LooseVersion(np.__version__)
1921

2022
def test_convert_overflow():
2123
"""
2224
Test reading an extremely large integer, which falls through to
2325
string due to an overflow error (#2234).
2426
"""
27+
# Before Numpy 1.6 the exception from np.array(['1' * 10000], dtype=np.int)
28+
# is exactly the same as np.array(['abc'], dtype=np.int). In this case
29+
# it falls through to float, so we just accept this as a known issue for
30+
# numpy < 1.6.
31+
expected_kind = ('f',) if _NUMPY_VERSION < version.LooseVersion('1.6') else ('S', 'U')
2532
dat = ascii.read(['a', '1' * 10000], format='basic', guess=False)
26-
assert dat['a'].dtype.kind in ('S', 'U')
33+
assert dat['a'].dtype.kind in expected_kind
2734

2835

2936
def test_guess_with_names_arg():

0 commit comments

Comments
 (0)