Skip to content

Commit 73ce021

Browse files
committed
Test exceptions
1 parent a0b3a51 commit 73ce021

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

pandas/computation/expr.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ def visit_Call(self, node, side=None, **kwargs):
546546
args += self.visit(node.starargs)
547547

548548
if node.keywords or node.kwargs:
549-
raise TypeError("Function {0} does not support keyword "
549+
raise TypeError("Function \"{0}\" does not support keyword "
550550
"arguments".format(res.name))
551551

552552
return res(*args, **kwargs)

pandas/computation/ops.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ def __unicode__(self):
520520
class FuncNode(object):
521521
def __init__(self, name):
522522
if name not in _mathops:
523-
raise ValueError("{0} is not a supported function".format(name))
523+
raise ValueError("\"{0}\" is not a supported function".format(name))
524524
self.name = name
525525
self.func = getattr(np, name)
526526

pandas/computation/tests/test_eval.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -1521,11 +1521,22 @@ def test_result_types(self):
15211521

15221522
def test_undefined_func(self):
15231523
df = DataFrame({'a': np.random.randn(10)})
1524-
with tm.assertRaises(ValueError):
1524+
with tm.assertRaisesRegexp(ValueError,
1525+
"\"mysin\" is not a supported function"):
15251526
df.eval("mysin(a)",
15261527
engine=self.engine,
15271528
parser=self.parser)
15281529

1530+
def test_keyword_arg(self):
1531+
df = DataFrame({'a': np.random.randn(10)})
1532+
with tm.assertRaisesRegexp(TypeError,
1533+
"Function \"sin\" does not support "
1534+
"keyword arguments"):
1535+
df.eval("sin(x=a)",
1536+
engine=self.engine,
1537+
parser=self.parser)
1538+
1539+
15291540
class TestMathPythonPandas(TestMathPythonPython):
15301541
@classmethod
15311542
def setUpClass(cls):

0 commit comments

Comments
 (0)