Test that ast nodes can be triggered with different modes
()
| 56 | |
| 57 | |
| 58 | def 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 | |
| 85 | def test_interactivehooks_ast_modes_semi_suppress(): |
| 86 | """ |
nothing calls this directly
no test coverage detected