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_save_breakpoints(mocker):
MockBP = collections.namedtuple('MockBreakpoint', 'file line cond')
mock_breakpoints = [MockBP('/home/user/test.py', 41, None),
MockBP('/home/user/test.py', 50, None)]
mocker.patch('pudb.settings.get_breakpoints_file_name',
mocker.Mock(return_value='saved-breakpoints'))
mock_open = mocker.mock_open()
mocker.patch.object(builtins, 'open', mock_open)
save_breakpoints(mock_breakpoints)
mock_open.assert_called_with('saved-breakpoints', 'w')
bps = []
if buffname in self._bps_placed:
for ln in self._bps_placed[buffname]:
bps.append(self.pudbbp(buffname, int(ln / 10)))
for bpt in self.iter_breakpoints():
if bpt.filename == buffname:
# we already placed these
continue
else:
# make sure we pass on anything we aren't messing with
bps.append(bpt)
__logger__.debug(
'Updating breakpoints in pudb:\n %s',
pprint.pformat(
list(map(lambda x: Breakpoint(x.filename, x.lineno), bps))))
pudb.settings.save_breakpoints(
list(map(lambda x: Breakpoint(x.filename, x.lineno), bps)))
def save_breakpoints(self):
from pudb.settings import save_breakpoints
save_breakpoints([
bp
for fn, bp_lst in self.get_all_breaks().items()
for lineno in bp_lst
for bp in self.get_breaks(fn, lineno)
if not bp.temporary])
def save_breakpoints(self):
from pudb.settings import save_breakpoints
save_breakpoints([
bp
for fn, bp_lst in self.get_all_breaks().iteritems()
for lineno in bp_lst
for bp in self.get_breaks(fn, lineno)
if not bp.temporary])