Skip to content

Commit 011e2c5

Browse files
author
y-p
committed
CLN: Use correct exception types in config.py machinery
1 parent b3f6972 commit 011e2c5

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

pandas/core/config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,13 @@ def _set_option(*args, **kwargs):
124124
# must at least 1 arg deal with constraints later
125125
nargs = len(args)
126126
if not nargs or nargs % 2 != 0:
127-
raise AssertionError("Must provide an even number of non-keyword "
127+
raise ValueError("Must provide an even number of non-keyword "
128128
"arguments")
129129

130130
# must be 0 or 1 kwargs
131131
nkwargs = len(kwargs)
132132
if nkwargs not in (0, 1):
133-
raise AssertionError("The can only be 0 or 1 keyword arguments")
133+
raise ValueError("The can only be 0 or 1 keyword arguments")
134134

135135
# if 1 kwarg then it must be silent=True or silent=False
136136
if nkwargs:
@@ -365,7 +365,7 @@ class option_context(object):
365365

366366
def __init__(self, *args):
367367
if not (len(args) % 2 == 0 and len(args) >= 2):
368-
raise AssertionError(
368+
raise ValueError(
369369
'Need to invoke as'
370370
'option_context(pat, val, [(pat, val), ...)).'
371371
)

pandas/tests/test_config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,14 @@ def test_set_option(self):
170170

171171

172172
def test_set_option_empty_args(self):
173-
self.assertRaises(AssertionError, self.cf.set_option)
173+
self.assertRaises(ValueError, self.cf.set_option)
174174

175175
def test_set_option_uneven_args(self):
176-
self.assertRaises(AssertionError, self.cf.set_option, 'a.b', 2, 'b.c')
176+
self.assertRaises(ValueError, self.cf.set_option, 'a.b', 2, 'b.c')
177177

178178

179179
def test_set_option_2_kwargs(self):
180-
self.assertRaises(AssertionError, self.cf.set_option, 'a.b', 2,
180+
self.assertRaises(ValueError, self.cf.set_option, 'a.b', 2,
181181
silenadf=2, asdf=2)
182182

183183
def test_set_option_invalid_kwargs_key(self):
@@ -189,7 +189,7 @@ def test_set_option_invalid_kwargs_value_type(self):
189189
silent=2)
190190

191191
def test_set_option_invalid_single_argument_type(self):
192-
self.assertRaises(AssertionError, self.cf.set_option, 2)
192+
self.assertRaises(ValueError, self.cf.set_option, 2)
193193

194194
def test_set_option_multiple(self):
195195
self.cf.register_option('a', 1, 'doc')

0 commit comments

Comments
 (0)