diff --git a/pytests/func/test_breakpoints.py b/pytests/func/test_breakpoints.py index c27c1150..9da742d3 100644 --- a/pytests/func/test_breakpoints.py +++ b/pytests/func/test_breakpoints.py @@ -17,16 +17,19 @@ BP_TEST_ROOT = get_test_root('bp') def test_path_with_ampersand(debug_session, start_method, run_as): bp_line = 4 testfile = os.path.join(BP_TEST_ROOT, 'a&b', 'test.py') - debug_session.initialize(target=(run_as, testfile), start_method=start_method) + + debug_session.initialize( + target=(run_as, testfile), + start_method=start_method, + ignore_unobserved=[Event('continued')], + ) debug_session.set_breakpoints(testfile, [bp_line]) debug_session.start_debugging() hit = debug_session.wait_for_thread_stopped() frames = hit.stacktrace.body['stackFrames'] assert compare_path(frames[0]['source']['path'], testfile, show=False) - continue_request = debug_session.send_request('continue') - debug_session.wait_for_next(Response(continue_request) & Event('continued')) - + debug_session.send_request('continue').wait_for_response() debug_session.wait_for_exit() @@ -34,7 +37,12 @@ def test_path_with_ampersand(debug_session, start_method, run_as): def test_path_with_unicode(debug_session, start_method, run_as): bp_line = 6 testfile = os.path.join(BP_TEST_ROOT, u'ನನ್ನ_ಸ್ಕ್ರಿಪ್ಟ್.py') - debug_session.initialize(target=(run_as, testfile), start_method=start_method) + + debug_session.initialize( + target=(run_as, testfile), + start_method=start_method, + ignore_unobserved=[Event('continued')], + ) debug_session.set_breakpoints(testfile, [bp_line]) debug_session.start_debugging() hit = debug_session.wait_for_thread_stopped() @@ -42,7 +50,5 @@ def test_path_with_unicode(debug_session, start_method, run_as): assert compare_path(frames[0]['source']['path'], testfile, show=False) assert u'ಏನಾದರೂ_ಮಾಡು' == frames[0]['name'] - continue_request = debug_session.send_request('continue') - debug_session.wait_for_next(Response(continue_request) & Event('continued')) - + debug_session.send_request('continue').wait_for_response() debug_session.wait_for_exit() diff --git a/pytests/func/test_completions.py b/pytests/func/test_completions.py index 18b81dcd..5e6c3e9f 100644 --- a/pytests/func/test_completions.py +++ b/pytests/func/test_completions.py @@ -46,11 +46,12 @@ def test_completions_scope(debug_session, pyfile, bp_line, run_as, start_method) print('done') expected = expected_at_line[bp_line] - debug_session.ignore_unobserved += [ - Event('stopped'), - Event('continued') - ] - debug_session.initialize(target=(run_as, code_to_debug), start_method=start_method) + + debug_session.initialize( + target=(run_as, code_to_debug), + start_method=start_method, + ignore_unobserved=[Event('stopped'), Event('continued')], + ) debug_session.set_breakpoints(code_to_debug, [bp_line]) debug_session.start_debugging() @@ -74,7 +75,6 @@ def test_completions_scope(debug_session, pyfile, bp_line, run_as, start_method) targets = resp_completions.body['targets'] debug_session.send_request('continue').wait_for_response() - debug_session.wait_for_next(Event('continued')) targets.sort(key=lambda t: t['label']) expected.sort(key=lambda t: t['label']) @@ -95,7 +95,12 @@ def test_completions(debug_session, pyfile, start_method, run_as): bp_line = 6 bp_file = code_to_debug - debug_session.initialize(target=(run_as, bp_file), start_method=start_method) + + debug_session.initialize( + target=(run_as, bp_file), + start_method=start_method, + ignore_unobserved=[Event('continued')], + ) debug_session.set_breakpoints(bp_file, [bp_line]) debug_session.start_debugging() hit = debug_session.wait_for_thread_stopped() @@ -116,6 +121,4 @@ def test_completions(debug_session, pyfile, start_method, run_as): assert not response.body['targets'] debug_session.send_request('continue').wait_for_response() - debug_session.wait_for_next(Event('continued')) - debug_session.wait_for_exit() diff --git a/pytests/func/test_django.py b/pytests/func/test_django.py index 51b7cc2a..2d505618 100644 --- a/pytests/func/test_django.py +++ b/pytests/func/test_django.py @@ -36,6 +36,7 @@ def test_django_breakpoint_no_multiproc(debug_session, bp_file, bp_line, bp_name debug_options=['Django'], cwd=DJANGO1_ROOT, expected_returncode=ANY.int, # No clean way to kill Flask server + ignore_unobserved=[Event('continued')], ) bp_var_content = 'Django-Django-Test' @@ -87,7 +88,6 @@ def test_django_breakpoint_no_multiproc(debug_session, bp_file, bp_line, bp_name }] debug_session.send_request('continue').wait_for_response() - debug_session.wait_for_next(Event('continued')) web_content = web_request.wait_for_response() assert web_content.find(bp_var_content) != -1 @@ -112,6 +112,7 @@ def test_django_exception_no_multiproc(debug_session, ex_type, ex_line, start_me debug_options=['Django'], cwd=DJANGO1_ROOT, expected_returncode=ANY.int, # No clean way to kill Flask server + ignore_unobserved=[Event('continued')], ) debug_session.send_request('setExceptionBreakpoints', arguments={ @@ -168,7 +169,6 @@ def test_django_exception_no_multiproc(debug_session, ex_type, ex_line, start_me } debug_session.send_request('continue').wait_for_response() - debug_session.wait_for_next(Event('continued')) # ignore response for exception tests web_request.wait_for_response() @@ -203,7 +203,7 @@ def test_django_breakpoint_multiproc(debug_session, start_method): program_args=['runserver', ], debug_options=['Django'], cwd=DJANGO1_ROOT, - ignore_events=[Event('stopped'), Event('continued')], + ignore_unobserved=[Event('stopped'), Event('continued')], expected_returncode=ANY.int, # No clean way to kill Flask server ) @@ -270,7 +270,6 @@ def test_django_breakpoint_multiproc(debug_session, start_method): }] child_session.send_request('continue').wait_for_response() - child_session.wait_for_next(Event('continued')) web_content = web_request.wait_for_response() assert web_content.find(bp_var_content) != -1 diff --git a/pytests/func/test_evaluate.py b/pytests/func/test_evaluate.py index 785c30db..2ec5f625 100644 --- a/pytests/func/test_evaluate.py +++ b/pytests/func/test_evaluate.py @@ -22,7 +22,12 @@ def test_variables_and_evaluate(debug_session, pyfile, run_as, start_method): bp_line = 6 bp_file = code_to_debug - debug_session.initialize(target=(run_as, bp_file), start_method=start_method) + + debug_session.initialize( + target=(run_as, bp_file), + start_method=start_method, + ignore_unobserved=[Event('continued')], + ) debug_session.set_breakpoints(bp_file, [bp_line]) debug_session.start_debugging() hit = debug_session.wait_for_thread_stopped() @@ -95,8 +100,6 @@ def test_variables_and_evaluate(debug_session, pyfile, run_as, start_method): }) debug_session.send_request('continue').wait_for_response() - debug_session.wait_for_next(Event('continued')) - debug_session.wait_for_exit() @@ -110,7 +113,12 @@ def test_set_variable(debug_session, pyfile, run_as, start_method): bp_line = 4 bp_file = code_to_debug - debug_session.initialize(target=(run_as, bp_file), start_method=start_method) + + debug_session.initialize( + target=(run_as, bp_file), + start_method=start_method, + ignore_unobserved=[Event('continued')], + ) debug_session.set_breakpoints(bp_file, [bp_line]) debug_session.start_debugging() hit = debug_session.wait_for_thread_stopped() @@ -144,7 +152,6 @@ def test_set_variable(debug_session, pyfile, run_as, start_method): }) debug_session.send_request('continue').wait_for_response() - debug_session.wait_for_next(Event('continued')) debug_session.wait_for_next(Event('output')) output = [e for e in debug_session.all_occurrences_of(Event('output')) @@ -177,7 +184,12 @@ def test_variable_sort(debug_session, pyfile, run_as, start_method): bp_line = 15 bp_file = code_to_debug - debug_session.initialize(target=(run_as, bp_file), start_method=start_method) + + debug_session.initialize( + target=(run_as, bp_file), + start_method=start_method, + ignore_unobserved=[Event('continued')], + ) debug_session.set_breakpoints(bp_file, [bp_line]) debug_session.start_debugging() hit = debug_session.wait_for_thread_stopped() @@ -221,6 +233,4 @@ def test_variable_sort(debug_session, pyfile, run_as, start_method): # assert variable_names[:3] == ['1', '2', '10'] debug_session.send_request('continue').wait_for_response() - debug_session.wait_for_next(Event('continued')) - debug_session.wait_for_exit() diff --git a/pytests/func/test_flask.py b/pytests/func/test_flask.py index 024f5808..ffec7b53 100644 --- a/pytests/func/test_flask.py +++ b/pytests/func/test_flask.py @@ -40,7 +40,7 @@ def _flask_no_multiproc_common(debug_session, start_method): start_method=start_method, target=('module', 'flask'), program_args=['run', '--no-debugger', '--no-reload', '--with-threads'], - ignore_events=[Event('stopped'), Event('continued')], + ignore_unobserved=[Event('stopped'), Event('continued')], debug_options=['Jinja'], cwd=FLASK1_ROOT, env=env, @@ -107,7 +107,6 @@ def test_flask_breakpoint_no_multiproc(debug_session, bp_file, bp_line, bp_name, }] debug_session.send_request('continue').wait_for_response() - debug_session.wait_for_next(Event('continued')) web_content = web_request.wait_for_response() assert web_content.find(bp_var_content) != -1 @@ -182,7 +181,6 @@ def test_flask_exception_no_multiproc(debug_session, ex_type, ex_line, start_met } debug_session.send_request('continue').wait_for_response() - debug_session.wait_for_next(Event('continued')) # ignore response for exception tests web_request.wait_for_response() @@ -228,7 +226,7 @@ def test_flask_breakpoint_multiproc(debug_session, start_method): target=('module', 'flask'), multiprocess=True, program_args=['run', ], - ignore_events=[Event('stopped'), Event('continued')], + ignore_unobserved=[Event('stopped'), Event('continued')], debug_options=['Jinja'], cwd=FLASK1_ROOT, env=env, @@ -292,7 +290,6 @@ def test_flask_breakpoint_multiproc(debug_session, start_method): }] child_session.send_request('continue').wait_for_response() - child_session.wait_for_next(Event('continued')) web_content = web_request.wait_for_response() assert web_content.find(bp_var_content) != -1 diff --git a/pytests/func/test_start_stop.py b/pytests/func/test_start_stop.py index 2bc33d7d..9fddfd09 100644 --- a/pytests/func/test_start_stop.py +++ b/pytests/func/test_start_stop.py @@ -24,7 +24,11 @@ def test_break_on_entry(debug_session, pyfile, run_as, start_method): print('three') debug_session.debug_options += ['StopOnEntry'] - debug_session.initialize(target=(run_as, code_to_debug), start_method=start_method) + debug_session.initialize( + target=(run_as, code_to_debug), + start_method=start_method, + ignore_unobserved=[Event('continued')], + ) debug_session.start_debugging() thread_stopped = debug_session.wait_for_next(Event('stopped', ANY.dict_with({'reason': 'step'}))) @@ -40,7 +44,6 @@ def test_break_on_entry(debug_session, pyfile, run_as, start_method): assert frames[0]['line'] == 1 debug_session.send_request('continue').wait_for_response() - debug_session.wait_for_next(Event('continued')) debug_session.wait_for_termination() @@ -68,13 +71,16 @@ def test_wait_on_normal_exit_enabled(debug_session, pyfile, run_as, start_method bp_line = 5 bp_file = code_to_debug - debug_session.initialize(target=(run_as, bp_file), start_method=start_method) + debug_session.initialize( + target=(run_as, bp_file), + start_method=start_method, + ignore_unobserved=[Event('continued')], + ) debug_session.set_breakpoints(bp_file, [bp_line]) debug_session.start_debugging() debug_session.wait_for_next(Event('stopped', ANY.dict_with({'reason': 'breakpoint'}))) debug_session.send_request('continue').wait_for_response() - debug_session.wait_for_next(Event('continued')) debug_session.proceed() debug_session.expected_returncode = ANY.int @@ -114,13 +120,16 @@ def test_wait_on_abnormal_exit_enabled(debug_session, pyfile, run_as, start_meth bp_line = 7 bp_file = code_to_debug - debug_session.initialize(target=(run_as, bp_file), start_method=start_method) + debug_session.initialize( + target=(run_as, bp_file), + start_method=start_method, + ignore_unobserved=[Event('continued')], + ) debug_session.set_breakpoints(bp_file, [bp_line]) debug_session.start_debugging() debug_session.wait_for_next(Event('stopped'), ANY.dict_with({'reason': 'breakpoint'})) debug_session.send_request('continue').wait_for_response() - debug_session.wait_for_next(Event('continued')) debug_session.proceed() debug_session.expected_returncode = ANY.int @@ -156,13 +165,16 @@ def test_exit_normally_with_wait_on_abnormal_exit_enabled(debug_session, pyfile, bp_line = 5 bp_file = code_to_debug - debug_session.initialize(target=(run_as, bp_file), start_method=start_method) + debug_session.initialize( + target=(run_as, bp_file), + start_method=start_method, + ignore_unobserved=[Event('continued')], + ) debug_session.set_breakpoints(bp_file, [bp_line]) debug_session.start_debugging() debug_session.wait_for_next(Event('stopped', ANY.dict_with({'reason': 'breakpoint'}))) debug_session.send_request('continue').wait_for_response() - debug_session.wait_for_next(Event('continued')) debug_session.proceed() debug_session.wait_for_termination() diff --git a/pytests/helpers/session.py b/pytests/helpers/session.py index 03251819..af8646f7 100644 --- a/pytests/helpers/session.py +++ b/pytests/helpers/session.py @@ -87,6 +87,7 @@ class DebugSession(object): self.expect_new = self.timeline.expect_new self.expect_realized = self.timeline.expect_realized self.all_occurrences_of = self.timeline.all_occurrences_of + self.observe_all = self.timeline.observe_all def __contains__(self, expectation): return expectation in self.timeline @@ -523,7 +524,7 @@ class DebugSession(object): self.ignore_unobserved += [ Event('thread', ANY.dict_with({'reason': 'started'})), Event('module') - ] + kwargs.pop('ignore_events', []) + ] + kwargs.pop('ignore_unobserved', []) self.env.update(kwargs.pop('env', {})) self.debug_options += kwargs.pop('debug_options', [])