From 7953182c83fb68f1a0fe857fa5062a2265e39047 2013-05-15 03:11:29 From: MinRK Date: 2013-05-15 03:11:29 Subject: [PATCH] test user_variables/expressions in message spec --- diff --git a/IPython/kernel/tests/test_message_spec.py b/IPython/kernel/tests/test_message_spec.py index 1d2ee3c..47bd922 100644 --- a/IPython/kernel/tests/test_message_spec.py +++ b/IPython/kernel/tests/test_message_spec.py @@ -361,7 +361,21 @@ def test_user_variables(): msg_id, reply = execute(code='x=1', user_variables=['x']) user_variables = reply['user_variables'] - nt.assert_equal(user_variables, {u'x' : u'1'}) + nt.assert_equal(user_variables, {u'x': { + u'status': u'ok', + u'data': {u'text/plain': u'1'}, + u'metadata': {}, + }}) + + +def test_user_variables_fail(): + flush_channels() + + msg_id, reply = execute(code='x=1', user_variables=['nosuchname']) + user_variables = reply['user_variables'] + foo = user_variables['nosuchname'] + nt.assert_equal(foo['status'], 'error') + nt.assert_equal(foo['ename'], 'KeyError') def test_user_expressions(): @@ -369,7 +383,21 @@ def test_user_expressions(): msg_id, reply = execute(code='x=1', user_expressions=dict(foo='x+1')) user_expressions = reply['user_expressions'] - nt.assert_equal(user_expressions, {u'foo' : u'2'}) + nt.assert_equal(user_expressions, {u'foo': { + u'status': u'ok', + u'data': {u'text/plain': u'2'}, + u'metadata': {}, + }}) + + +def test_user_expressions_fail(): + flush_channels() + + msg_id, reply = execute(code='x=0', user_expressions=dict(foo='nosuchname')) + user_expressions = reply['user_expressions'] + foo = user_expressions['foo'] + nt.assert_equal(foo['status'], 'error') + nt.assert_equal(foo['ename'], 'NameError') @dec.parametric