diff options
Diffstat (limited to 'numpy/lib')
-rw-r--r-- | numpy/lib/_iotools.py | 7 | ||||
-rw-r--r-- | numpy/lib/tests/test__iotools.py | 6 |
2 files changed, 9 insertions, 4 deletions
diff --git a/numpy/lib/_iotools.py b/numpy/lib/_iotools.py index f2adcda10..316704b42 100644 --- a/numpy/lib/_iotools.py +++ b/numpy/lib/_iotools.py @@ -320,12 +320,13 @@ class NameValidator(object): # Process the case option ..... if (case_sensitive is None) or (case_sensitive is True): self.case_converter = lambda x: x - elif (case_sensitive is False) or ('u' in case_sensitive): + elif (case_sensitive is False) or case_sensitive.startswith('u'): self.case_converter = lambda x: x.upper() - elif 'l' in case_sensitive: + elif case_sensitive.startswith('l'): self.case_converter = lambda x: x.lower() else: - self.case_converter = lambda x: x + msg = 'unrecognized case_sensitive value %s.' % case_sensitive + raise ValueError(msg) # self.replace_space = replace_space diff --git a/numpy/lib/tests/test__iotools.py b/numpy/lib/tests/test__iotools.py index 92ca1c973..060f815d5 100644 --- a/numpy/lib/tests/test__iotools.py +++ b/numpy/lib/tests/test__iotools.py @@ -7,7 +7,8 @@ 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, assert_allclose + run_module_suite, TestCase, assert_, assert_equal, assert_allclose, + assert_raises ) from numpy.lib._iotools import ( LineSplitter, NameValidator, StringConverter, @@ -93,6 +94,9 @@ class TestNameValidator(TestCase): test = NameValidator(case_sensitive='lower').validate(names) assert_equal(test, ['a', 'a_1', 'b', 'c']) + # check exceptions + assert_raises(ValueError, NameValidator, case_sensitive='foobar') + def test_excludelist(self): "Test excludelist" names = ['dates', 'data', 'Other Data', 'mask'] |