Skip to content

Commit c028b97

Browse files
committed
TST: changes AssertionErrors in core/generic/_construct_axes_from_arguments to Type/Value Errors
1 parent 1d411b9 commit c028b97

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

pandas/core/generic.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def _construct_axes_from_arguments(self, args, kwargs, require_all=False):
233233
if alias is not None:
234234
if a in kwargs:
235235
if alias in kwargs:
236-
raise Exception(
236+
raise TypeError(
237237
"arguments are multually exclusive for [%s,%s]" % (a, alias))
238238
continue
239239
if alias in kwargs:
@@ -246,8 +246,8 @@ def _construct_axes_from_arguments(self, args, kwargs, require_all=False):
246246
kwargs[a] = args.pop(0)
247247
except (IndexError):
248248
if require_all:
249-
raise AssertionError(
250-
"not enough arguments specified!")
249+
raise TypeError(
250+
"not enough/duplicate arguments specified!")
251251

252252
axes = dict([(a, kwargs.get(a)) for a in self._AXIS_ORDERS])
253253
return axes, kwargs

pandas/tests/test_panel.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -1248,14 +1248,12 @@ def test_transpose(self):
12481248
expected = self.panel.swapaxes('items', 'minor')
12491249
assert_panel_equal(result, expected)
12501250

1251-
## test bad aliases
1252-
# test ambiguous aliases
1253-
self.assertRaises(AssertionError, self.panel.transpose, 'minor',
1254-
maj='major', majo='items')
1255-
1256-
# test invalid kwargs
1257-
self.assertRaises(AssertionError, self.panel.transpose, 'minor',
1258-
maj='major', minor='items')
1251+
# duplicate axes
1252+
with tm.assertRaisesRegexp(TypeError, 'not enough/duplicate arguments'):
1253+
self.panel.transpose('minor', maj='major', minor='items')
1254+
1255+
with tm.assertRaisesRegexp(ValueError, 'repeated axis in transpose'):
1256+
self.panel.transpose('minor', 'major', major='minor', minor='items')
12591257

12601258
result = self.panel.transpose(2, 1, 0)
12611259
assert_panel_equal(result, expected)

0 commit comments

Comments
 (0)