diff options
author | Garrett-R <garrettreynolds5@gmail.com> | 2014-11-29 23:35:56 -0800 |
---|---|---|
committer | Garrett-R <garrettreynolds5@gmail.com> | 2014-11-30 01:07:15 -0800 |
commit | b82388e32ab4c717fd952fa4b8b0ece5512c9972 (patch) | |
tree | cde6c1fb87c6efdb38808b453297d8772f5fff2d /numpy/lib/tests/test__iotools.py | |
parent | 0afa5fc05032cacae38280063544ca5d315d6d1d (diff) | |
download | numpy-b82388e32ab4c717fd952fa4b8b0ece5512c9972.tar.gz |
BUG: Closes #2917: numpy.lib._iotools.StringConverter.upgrade return
numpy.lib._iotools.StringConverter.upgrade should have a return value
Diffstat (limited to 'numpy/lib/tests/test__iotools.py')
-rw-r--r-- | numpy/lib/tests/test__iotools.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/numpy/lib/tests/test__iotools.py b/numpy/lib/tests/test__iotools.py index 4db19382a..92ca1c973 100644 --- a/numpy/lib/tests/test__iotools.py +++ b/numpy/lib/tests/test__iotools.py @@ -7,7 +7,7 @@ from datetime import date import numpy as np from numpy.compat import asbytes, asbytes_nested from numpy.testing import ( - run_module_suite, TestCase, assert_, assert_equal + run_module_suite, TestCase, assert_, assert_equal, assert_allclose ) from numpy.lib._iotools import ( LineSplitter, NameValidator, StringConverter, @@ -76,7 +76,7 @@ class TestLineSplitter(TestCase): test = LineSplitter((6, 6, 9))(strg) assert_equal(test, asbytes_nested(['1', '3 4', '5 6'])) -#------------------------------------------------------------------------------- +# ----------------------------------------------------------------------------- class TestNameValidator(TestCase): @@ -127,7 +127,7 @@ class TestNameValidator(TestCase): assert_(validator(namelist) is None) assert_equal(validator(namelist, nbfields=3), ['f0', 'f1', 'f2']) -#------------------------------------------------------------------------------- +# ----------------------------------------------------------------------------- def _bytes_to_date(s): @@ -150,13 +150,17 @@ class TestStringConverter(TestCase): "Tests the upgrade method." converter = StringConverter() assert_equal(converter._status, 0) - converter.upgrade(asbytes('0')) + # test int + assert_equal(converter.upgrade(asbytes('0')), 0) assert_equal(converter._status, 1) - converter.upgrade(asbytes('0.')) + # test float + assert_allclose(converter.upgrade(asbytes('0.')), 0.0) assert_equal(converter._status, 2) - converter.upgrade(asbytes('0j')) + # test complex + assert_equal(converter.upgrade(asbytes('0j')), complex('0j')) assert_equal(converter._status, 3) - converter.upgrade(asbytes('a')) + # test str + assert_equal(converter.upgrade(asbytes('a')), asbytes('a')) assert_equal(converter._status, len(converter._mapper) - 1) def test_missing(self): |