def test_confirm(self): """Test interface.user.UserInterface.confirm()""" d, cp = dbg_setup() u = Muser.UserInterface() for s in ['y', 'Y', 'Yes', ' YES ']: u.input.readline = lambda prompt=None: self.readline(s) self.assertTrue(u.confirm('Testing', True)) pass for s in ['n', 'N', 'No', ' NO ']: u.input.readline = lambda prompt=None: self.readline(s) self.assertFalse(u.confirm('Testing', True)) pass # FIXME: Add checking default values. Checking looping # values return
def __init__(self, opts=None): """Create a debugger object. But depending on the value of key 'start' inside hash 'opts', we may or may not initially start debugging. See also Debugger.start and Debugger.stop. """ import trepan.lib.core as Mcore self.mainpyfile = None self.thread = None self.eval_string = None get_option = lambda key: option_set(opts, key, self.DEFAULT_INIT_OPTS) completer = lambda text, state: self.complete(text, state) # set the instance variables that come directly from options. for opt in ('settings', 'orig_sys_argv', 'from_ipython'): setattr(self, opt, get_option(opt)) pass core_opts = {} for opt in ('ignore_filter', 'proc_opts', 'processor', 'step_ignore', 'processor',): core_opts[opt] = get_option(opt) pass # How is I/O for this debugger handled? This should # be set before calling DebuggerCore. interface_opts={'complete': completer} # FIXME when I pass in opts=opts things break interface = (get_option('interface') or Muser.UserInterface(opts=interface_opts)) self.intf = [interface] inp = get_option('input') if inp: self.intf[-1].input = inp pass out = get_option('output') if out: self.intf[-1].output = out pass self.core = Mcore.DebuggerCore(self, core_opts) self.core.add_ignore(self.core.stop) # When set True, we'll also suspend our debug-hook tracing. # This gives us a way to prevent or allow self debugging. self.core.trace_hook_suspend = False if get_option('save_sys_argv'): # Save the debugged program's sys.argv? We do this so that # when the debugged script munges these, we have a good # copy to use for an exec restart self.program_sys_argv = list(sys.argv) else: self.program_sys_argv = None pass self.sigmgr = Msig.SignalManager(self) # Were we requested to activate immediately? if get_option('activate'): self.core.start(get_option('start_opts')) pass return