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

Function test_interactivehooks_ast_modes_semi_suppress

tests/test_displayhook.py:88–107  ·  view source on GitHub ↗

Test that ast nodes can be triggered with different modes and suppressed by semicolon

()

Source from the content-addressed store, hash-verified

86
87
88def test_interactivehooks_ast_modes_semi_suppress():
89 """
90 Test that ast nodes can be triggered with different modes and suppressed
91 by semicolon
92 """
93 saved_mode = ip.ast_node_interactivity
94 ip.ast_node_interactivity = "last_expr_or_assign"
95
96 try:
97 with AssertNotPrints("2"):
98 ip.run_cell("x = 1+1;", store_history=True)
99
100 with AssertNotPrints("7"):
101 ip.run_cell("y = 1+6; # comment with a semicolon", store_history=True)
102
103 with AssertNotPrints("9"):
104 ip.run_cell("z = 1+8;\n#commented_out_function()", store_history=True)
105
106 finally:
107 ip.ast_node_interactivity = saved_mode
108
109
110def test_capture_display_hook_format():

Callers

nothing calls this directly

Calls 2

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…