MCPcopy Create free account
hub / github.com/ipython/ipython / test_interactivehooks_ast_modes

Function test_interactivehooks_ast_modes

IPython/core/tests/test_displayhook.py:58–83  ·  view source on GitHub ↗

Test that ast nodes can be triggered with different modes

()

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

AssertPrintsClass · 0.90
AssertNotPrintsClass · 0.90
run_cellMethod · 0.45

Tested by

no test coverage detected