Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_get_lines(self, mocker):
provider = FileSourceCodeProvider(mocker.Mock(), 'test file name')
result = provider.get_lines(mocker.MagicMock())
assert len(result) == 1
assert isinstance(result[0], SourceLine)
def test_string_file_name(self, mocker):
mock_debugger = mocker.Mock()
mock_debugger.canonic = mocker.Mock(return_value='')
provider = FileSourceCodeProvider(mock_debugger, 'test file name')
result = provider.get_lines(mocker.MagicMock())
assert len(result) == 1
assert isinstance(result[0], SourceLine)
def show_mod(mod):
filename = self.debugger.canonic(mod.__file__)
base, ext = splitext(filename)
if ext == ".pyc":
ext = ".py"
filename = base+".py"
self.set_source_code_provider(
FileSourceCodeProvider(self.debugger, filename))
self.source_list.set_focus(0)
filename = self.curframe.f_code.co_filename
import linecache
if not linecache.getlines(filename):
code = self.curframe.f_globals.get("_MODULE_SOURCE_CODE")
if code is not None:
self.ui.set_current_line(lineno,
DirectSourceCodeProvider(
self.curframe.f_code.co_name, code))
else:
self.ui.set_current_line(lineno,
NullSourceCodeProvider())
else:
self.ui.set_current_line(lineno,
FileSourceCodeProvider(self, filename))
self.ui.update_var_view()
self.ui.update_stack()
self.ui.stack_list._w.set_focus(self.ui.translate_ui_stack_index(index))
def show_breakpoint(w, size, key):
bp_entry, pos = self.bp_list._w.get_focus()
if bp_entry is not None:
bp = self._get_bp_list()[pos]
self.show_line(bp.line,
FileSourceCodeProvider(self.debugger, bp.file))
None,
("Delete", "del"),
("Location", "loc"),
], title="Edit Breakpoint")
if result is True:
bp.enabled = enabled_checkbox.get_state()
bp.ignore = int(ign_count_edit.value())
cond = cond_edit.get_edit_text()
if cond:
bp.cond = cond
else:
bp.cond = None
elif result == "loc":
self.show_line(bp.line,
FileSourceCodeProvider(self.debugger, bp.file))
self.columns.set_focus(0)
elif result == "del":
bp_source_identifier = \
self.source_code_provider.get_breakpoint_source_identifier()
if bp_source_identifier is None:
self.message(
"Cannot currently delete a breakpoint here--"
"source code does not correspond to a file location. "
"(perhaps this is generated code)")
if bp_source_identifier == bp.file:
self.source[bp.line-1].set_breakpoint(False)
err = self.debugger.clear_break(bp.file, bp.line)
if err: