Skip to content

Commit

Permalink
Test ParsedCommand.evaluate_test
Browse files Browse the repository at this point in the history
  • Loading branch information
astrofrog committed May 3, 2016
1 parent c7b17dd commit 0d78c79
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions glue/core/tests/test_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,22 @@ def test_evaluate_math(self):
pc = parse.ParsedCommand(cmd, refs)
assert pc.evaluate(data) == 1

def test_evaluate_test(self):

data = MagicMock()
c1 = ComponentID('c1')
data.__getitem__.return_value = 10
refs = {'comp1': c1}

cmd = 'numpy.log10({comp1}) + 3.4 - {comp1}'
pc = parse.ParsedCommand(cmd, refs)
pc.evaluate_test()

cmd = 'nump.log10({comp1}) + 3.4 - {comp1}'
pc = parse.ParsedCommand(cmd, refs)
with pytest.raises(NameError) as exc:
pc.evaluate_test()
assert exc.value.args[0] == "name 'nump' is not defined"


class TestParsedComponentLink(object):
Expand Down

0 comments on commit 0d78c79

Please sign in to comment.