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

Function test_interactivehooks_ast_modes

tests/test_displayhook.py:60–85  ·  view source on GitHub ↗

Test that ast nodes can be triggered with different modes

()

Source from the content-addressed store, hash-verified

58
59
60def test_interactivehooks_ast_modes():
61 """
62 Test that ast nodes can be triggered with different modes
63 """
64 saved_mode = ip.ast_node_interactivity
65 ip.ast_node_interactivity = "last_expr_or_assign"
66
67 try:
68 with AssertPrints("2"):
69 ip.run_cell("a = 1+1", store_history=True)
70
71 with AssertPrints("9"):
72 ip.run_cell("b = 1+8 # comment with a semicolon;", store_history=False)
73
74 with AssertPrints("7"):
75 ip.run_cell("c = 1+6\n#commented_out_function();", store_history=True)
76
77 ip.run_cell("d = 11", store_history=True)
78 with AssertPrints("12"):
79 ip.run_cell("d += 1", store_history=True)
80
81 with AssertNotPrints("42"):
82 ip.run_cell("(u,v) = (41+1, 43-1)")
83
84 finally:
85 ip.ast_node_interactivity = saved_mode
86
87
88def test_interactivehooks_ast_modes_semi_suppress():

Callers

nothing calls this directly

Calls 3

AssertPrintsClass · 0.90
AssertNotPrintsClass · 0.90
run_cellMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…