MCPcopy Index your code
hub / github.com/ipython/ipython / test_user_expression

Function test_user_expression

tests/test_interactiveshell.py:1022–1046  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1020
1021
1022def test_user_expression():
1023 # enable all formatters
1024 ip.display_formatter.active_types = ip.display_formatter.format_types
1025 query = {
1026 "a": "1 + 2",
1027 "b": "1/0",
1028 }
1029 r = ip.user_expressions(query)
1030 import pprint
1031
1032 pprint.pprint(r)
1033 assert set(r.keys()) == set(query.keys())
1034 a = r["a"]
1035 assert {"status", "data", "metadata"} == set(a.keys())
1036 assert a["status"] == "ok"
1037 data = a["data"]
1038 metadata = a["metadata"]
1039 assert data.get("text/plain") == "3"
1040
1041 b = r["b"]
1042 assert b["status"] == "error"
1043 assert b["ename"] == "ZeroDivisionError"
1044
1045 # back to text only
1046 ip.display_formatter.active_types = ["text/plain"]
1047
1048
1049class TestSyntaxErrorTransformer(unittest.TestCase):

Callers

nothing calls this directly

Calls 4

user_expressionsMethod · 0.80
pprintMethod · 0.80
keysMethod · 0.80
getMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…