Pass 'removed' instead of 'remove' to on_breakpoints_changed. #1118 (#1120)

This commit is contained in:
Karthik Nadig 2019-01-24 09:37:18 -08:00 committed by GitHub
parent 1bc879c16f
commit 40cbf494a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 9 deletions

View file

@ -421,8 +421,8 @@ class PyDevdAPI(object):
except:
pydev_log.debug("Error while removing exception %s" % sys.exc_info()[0])
py_db.on_breakpoints_changed(remove=True)
py_db.on_breakpoints_changed(removed=True)
def remove_plugins_exception_breakpoint(self, py_db, exception_type, exception):
# I.e.: no need to initialize lazy (if we didn't have it in the first place, we can't remove
# anything from it anyways).
@ -437,6 +437,5 @@ class PyDevdAPI(object):
else:
raise NameError(exception_type)
py_db.on_breakpoints_changed(remove=True)
py_db.on_breakpoints_changed(removed=True)

View file

@ -6,7 +6,7 @@ import pytest
from tests_python import debugger_unittest
from tests_python.debugger_unittest import get_free_port, overrides, IS_CPYTHON, IS_JYTHON, IS_IRONPYTHON, \
IS_PY3K
IS_PY3K, CMD_ADD_DJANGO_EXCEPTION_BREAK, CMD_REMOVE_DJANGO_EXCEPTION_BREAK
import sys
@ -187,6 +187,12 @@ class AbstractWriterThreadCaseDjango(debugger_unittest.AbstractWriterThread):
self.log.append('write_add_django_breakpoint: %s line: %s func: %s' % (breakpoint_id, line, func))
return breakpoint_id
def write_add_exception_breakpoint_django(self, exception='Exception'):
self.write('%s\t%s\t%s' % (CMD_ADD_DJANGO_EXCEPTION_BREAK, self.next_seq(), exception))
def write_remove_exception_breakpoint_django(self, exception='Exception'):
self.write('%s\t%s\t%s' % (CMD_REMOVE_DJANGO_EXCEPTION_BREAK, self.next_seq(), exception))
def create_request_thread(self, uri):
outer = self

View file

@ -955,6 +955,9 @@ class AbstractWriterThread(threading.Thread):
exception, notify_on_handled_exceptions, notify_on_unhandled_exceptions, ignore_libraries])))
self.log.append('write_add_exception_breakpoint: %s' % (exception,))
def write_remove_exception_breakpoint(self, exception):
self.write('%s\t%s\t%s' % (CMD_REMOVE_EXCEPTION_BREAK, self.next_seq(), exception))
def write_remove_breakpoint(self, breakpoint_id):
self.write("%s\t%s\t%s\t%s\t%s" % (
CMD_REMOVE_BREAK, self.next_seq(), 'python-line', self.get_main_filename(), breakpoint_id))

View file

@ -945,6 +945,8 @@ def test_case_django_a(case_setup_django):
def test_case_django_b(case_setup_django):
with case_setup_django.test_file(EXPECTED_RETURNCODE='any') as writer:
writer.write_add_breakpoint_django(4, None, 'name.html')
writer.write_add_exception_breakpoint_django()
writer.write_remove_exception_breakpoint_django()
writer.write_make_initial_run()
t = writer.create_request_thread('my_app/name')
@ -2378,8 +2380,9 @@ def test_remote_debugger_multi_proc(case_setup_remote):
writer.finished_ok = True
@pytest.mark.parametrize('handle', [True, False])
@pytest.mark.skipif(not IS_CPYTHON, reason='CPython only test.')
def test_remote_unhandled_exceptions(case_setup_remote):
def test_remote_unhandled_exceptions(case_setup_remote, handle):
def check_test_suceeded_msg(writer, stdout, stderr):
return 'TEST SUCEEDED' in ''.join(stderr)
@ -2400,14 +2403,21 @@ def test_remote_unhandled_exceptions(case_setup_remote):
writer.log.append('waiting for breakpoint hit')
hit = writer.wait_for_breakpoint_hit()
# Add, remove and add back
writer.write_add_exception_breakpoint_with_policy('Exception', '0', '1', '0')
writer.write_remove_exception_breakpoint('Exception')
writer.write_add_exception_breakpoint_with_policy('Exception', '0', '1', '0')
if not handle:
writer.write_remove_exception_breakpoint('Exception')
writer.log.append('run thread')
writer.write_run_thread(hit.thread_id)
writer.log.append('waiting for uncaught exception')
hit = writer.wait_for_breakpoint_hit(REASON_UNCAUGHT_EXCEPTION)
writer.write_run_thread(hit.thread_id)
if handle:
writer.log.append('waiting for uncaught exception')
hit = writer.wait_for_breakpoint_hit(REASON_UNCAUGHT_EXCEPTION)
writer.write_run_thread(hit.thread_id)
writer.log.append('finished ok')
writer.finished_ok = True