(case_setup_dap)
| 2648 | |
| 2649 | |
| 2650 | def test_evaluate_exec_unicode(case_setup_dap): |
| 2651 | |
| 2652 | def get_environ(writer): |
| 2653 | env = os.environ.copy() |
| 2654 | |
| 2655 | env["PYTHONIOENCODING"] = "utf-8" |
| 2656 | return env |
| 2657 | |
| 2658 | with case_setup_dap.test_file("_debugger_case_local_variables2.py", get_environ=get_environ) as writer: |
| 2659 | json_facade = JsonFacade(writer) |
| 2660 | writer.write_start_redirect() |
| 2661 | |
| 2662 | writer.write_add_breakpoint(writer.get_line_index_with_content("Break here")) |
| 2663 | json_facade.write_make_initial_run() |
| 2664 | |
| 2665 | json_hit = json_facade.wait_for_thread_stopped() |
| 2666 | json_hit = json_facade.get_stack_as_json_hit(json_hit.thread_id) |
| 2667 | |
| 2668 | # Check eval |
| 2669 | json_facade.evaluate( |
| 2670 | "print(u'中')", |
| 2671 | frameId=json_hit.frame_id, |
| 2672 | context="repl", |
| 2673 | ) |
| 2674 | |
| 2675 | messages = json_facade.mark_messages( |
| 2676 | OutputEvent, lambda output_event: ("中" in output_event.body.output) and ("pydevd warning" not in output_event.body.output) |
| 2677 | ) |
| 2678 | assert len(messages) == 1 |
| 2679 | |
| 2680 | # Check exec |
| 2681 | json_facade.evaluate( |
| 2682 | "a=10;print(u'中')", |
| 2683 | frameId=json_hit.frame_id, |
| 2684 | context="repl", |
| 2685 | ) |
| 2686 | |
| 2687 | messages = json_facade.mark_messages( |
| 2688 | OutputEvent, lambda output_event: ("中" in output_event.body.output) and ("pydevd warning" not in output_event.body.output) |
| 2689 | ) |
| 2690 | assert len(messages) == 1 |
| 2691 | |
| 2692 | response = json_facade.evaluate( |
| 2693 | "u'中'", |
| 2694 | frameId=json_hit.frame_id, |
| 2695 | context="repl", |
| 2696 | ) |
| 2697 | assert response.body.result in ("u'\\u4e2d'", "'\u4e2d'") # py2 or py3 |
| 2698 | |
| 2699 | messages = json_facade.mark_messages( |
| 2700 | OutputEvent, lambda output_event: ("中" in output_event.body.output) and ("pydevd warning" not in output_event.body.output) |
| 2701 | ) |
| 2702 | assert len(messages) == 0 # i.e.: we don't print in this case. |
| 2703 | |
| 2704 | json_facade.write_continue() |
| 2705 | writer.finished_ok = True |
| 2706 | |
| 2707 |
nothing calls this directly
no test coverage detected