Test that ast nodes can be triggered with different modes
()
| 58 | |
| 59 | |
| 60 | def 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 | |
| 88 | def test_interactivehooks_ast_modes_semi_suppress(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…