def test_Expr_exception(self): c = Context() assert c.run_code("{}['k']")['result']['type'] == 'ErrorValue'
def test_multiline_ending_with_statement(self): c = Context() assert c.run_code("3\nx = 2")['result']['type'] == 'NullValue'
def test_run_code(self): c = Context() assert set(c.run_code("1").keys()) == set(['microseconds', 'result'])
def test_multiline_ending_with_expression(self): c = Context() import ast assert c.run_code("x = 2\n3")['result']['value'] == 3
def test_reset_clears_variables(self): c = Context() c.run_code("x = 123") assert c.run_code("locals().get('x')")['result']['value'] == 123 c.reset() assert c.run_code("locals().get('x')")['result']['type'] == 'NullValue'