Enable, fix quotes linting
This commit is contained in:
parent
fcf237e654
commit
21f0c2bba1
@ -4,6 +4,9 @@ class MyClass(object):
|
||||
self.b = b
|
||||
self._b = [b]
|
||||
|
||||
def safely_stringify_for_pudb(self):
|
||||
1/0
|
||||
|
||||
mc = MyClass(15, MyClass(12, None))
|
||||
|
||||
|
||||
|
@ -70,7 +70,7 @@ CURRENT_DEBUGGER = []
|
||||
|
||||
def _tty_override():
|
||||
import os
|
||||
return os.environ.get('PUDB_TTY')
|
||||
return os.environ.get("PUDB_TTY")
|
||||
|
||||
|
||||
def _open_tty(tty_path):
|
||||
@ -81,15 +81,15 @@ def _open_tty(tty_path):
|
||||
import fcntl
|
||||
import termios
|
||||
import struct
|
||||
tty_file = open(tty_path, 'r+b', buffering=0)
|
||||
tty_file = open(tty_path, "r+b", buffering=0)
|
||||
try:
|
||||
s = struct.unpack('hh', fcntl.ioctl(
|
||||
tty_file.fileno(), termios.TIOCGWINSZ, '1234'))
|
||||
s = struct.unpack("hh", fcntl.ioctl(
|
||||
tty_file.fileno(), termios.TIOCGWINSZ, "1234"))
|
||||
term_size = (s[1], s[0])
|
||||
except Exception:
|
||||
term_size = None
|
||||
else:
|
||||
tty_file = io.TextIOWrapper(open(tty_path, 'r+b', buffering=0))
|
||||
tty_file = io.TextIOWrapper(open(tty_path, "r+b", buffering=0))
|
||||
term_size = os.get_terminal_size(tty_file.fileno())
|
||||
|
||||
return tty_file, term_size
|
||||
@ -98,11 +98,11 @@ def _open_tty(tty_path):
|
||||
def _get_debugger(**kwargs):
|
||||
if not CURRENT_DEBUGGER:
|
||||
tty_path = _tty_override()
|
||||
if tty_path and ('stdin' not in kwargs or 'stdout' not in kwargs):
|
||||
if tty_path and ("stdin" not in kwargs or "stdout" not in kwargs):
|
||||
tty_file, term_size = _open_tty(tty_path)
|
||||
kwargs.setdefault('stdin', tty_file)
|
||||
kwargs.setdefault('stdout', tty_file)
|
||||
kwargs.setdefault('term_size', term_size)
|
||||
kwargs.setdefault("stdin", tty_file)
|
||||
kwargs.setdefault("stdout", tty_file)
|
||||
kwargs.setdefault("term_size", term_size)
|
||||
|
||||
from pudb.debugger import Debugger
|
||||
dbg = Debugger(**kwargs)
|
||||
@ -123,7 +123,7 @@ del signal
|
||||
|
||||
|
||||
def runmodule(*args, **kwargs):
|
||||
kwargs['run_as_module'] = True
|
||||
kwargs["run_as_module"] = True
|
||||
runscript(*args, **kwargs)
|
||||
|
||||
|
||||
@ -299,7 +299,7 @@ def set_interrupt_handler(interrupt_signal=None):
|
||||
from warnings import warn
|
||||
if old_handler is None:
|
||||
# This is the documented meaning of getsignal()->None.
|
||||
old_handler = 'not installed from python'
|
||||
old_handler = "not installed from python"
|
||||
return warn("A non-default handler for signal %d is already installed (%s). "
|
||||
"Skipping pudb interrupt support."
|
||||
% (interrupt_signal, old_handler))
|
||||
|
@ -5,14 +5,14 @@ from pudb import _get_debugger, set_interrupt_handler
|
||||
|
||||
|
||||
def __myimport__(name, *args, **kwargs): # noqa: N807
|
||||
if name == 'pudb.b':
|
||||
if name == "pudb.b":
|
||||
set_trace()
|
||||
return __origimport__(name, *args, **kwargs) # noqa: F821
|
||||
|
||||
|
||||
# Will only be run on first import
|
||||
__builtins__['__origimport__'] = __import__
|
||||
__builtins__['__import__'] = __myimport__
|
||||
__builtins__["__origimport__"] = __import__
|
||||
__builtins__["__import__"] = __myimport__
|
||||
|
||||
|
||||
def set_trace():
|
||||
|
@ -294,7 +294,7 @@ class Debugger(bdb.Bdb):
|
||||
|
||||
def setup_state(self):
|
||||
self.bottom_frame = None
|
||||
self.mainpyfile = ''
|
||||
self.mainpyfile = ""
|
||||
self._wait_for_mainpyfile = False
|
||||
self.current_bp = None
|
||||
self.post_mortem = False
|
||||
@ -412,7 +412,7 @@ class Debugger(bdb.Bdb):
|
||||
def user_line(self, frame):
|
||||
"""This function is called when we stop or break at this line."""
|
||||
if "__exc_tuple__" in frame.f_locals:
|
||||
del frame.f_locals['__exc_tuple__']
|
||||
del frame.f_locals["__exc_tuple__"]
|
||||
|
||||
if self._wait_for_mainpyfile:
|
||||
if (self.mainpyfile != self.canonic(frame.f_code.co_filename)
|
||||
@ -432,8 +432,8 @@ class Debugger(bdb.Bdb):
|
||||
|
||||
def user_return(self, frame, return_value):
|
||||
"""This function is called when a return trap is set here."""
|
||||
if frame.f_code.co_name != '<module>':
|
||||
frame.f_locals['__return__'] = return_value
|
||||
if frame.f_code.co_name != "<module>":
|
||||
frame.f_locals["__return__"] = return_value
|
||||
|
||||
if self._wait_for_mainpyfile:
|
||||
if (self.mainpyfile != self.canonic(frame.f_code.co_filename)
|
||||
@ -448,7 +448,7 @@ class Debugger(bdb.Bdb):
|
||||
def user_exception(self, frame, exc_tuple):
|
||||
"""This function is called if an exception occurs,
|
||||
but only if we are to stop at or just below this level."""
|
||||
frame.f_locals['__exc_tuple__'] = exc_tuple
|
||||
frame.f_locals["__exc_tuple__"] = exc_tuple
|
||||
|
||||
if not self._wait_for_mainpyfile:
|
||||
self.interaction(frame, exc_tuple)
|
||||
@ -546,17 +546,17 @@ except ImportError:
|
||||
|
||||
|
||||
class ThreadsafeScreenMixin(object):
|
||||
"A Screen subclass that doesn't crash when running from a non-main thread."
|
||||
"""A Screen subclass that doesn't crash when running from a non-main thread."""
|
||||
|
||||
def signal_init(self):
|
||||
"Initialize signal handler, ignoring errors silently."
|
||||
"""Initialize signal handler, ignoring errors silently."""
|
||||
try:
|
||||
super(ThreadsafeScreenMixin, self).signal_init()
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
def signal_restore(self):
|
||||
"Restore default signal handler, ignoring errors silently."
|
||||
"""Restore default signal handler, ignoring errors silently."""
|
||||
try:
|
||||
super(ThreadsafeScreenMixin, self).signal_restore()
|
||||
except ValueError:
|
||||
@ -905,7 +905,7 @@ class DebuggerUI(FrameVarInfoKeeper):
|
||||
iinfo = get_inspect_info(var.id_path)
|
||||
focus_index = None
|
||||
|
||||
if key == "enter" or key == "\\" or key == ' ':
|
||||
if key == "enter" or key == "\\" or key == " ":
|
||||
iinfo.show_detail = not iinfo.show_detail
|
||||
elif key == "h":
|
||||
focus_index = collapse_current(var, pos, iinfo)
|
||||
@ -1078,8 +1078,8 @@ class DebuggerUI(FrameVarInfoKeeper):
|
||||
self.var_list.listen("n", insert_watch)
|
||||
self.var_list.listen("insert", insert_watch)
|
||||
|
||||
self.var_list.listen("[", partial(change_rhs_box, 'variables', 0, -1))
|
||||
self.var_list.listen("]", partial(change_rhs_box, 'variables', 0, 1))
|
||||
self.var_list.listen("[", partial(change_rhs_box, "variables", 0, -1))
|
||||
self.var_list.listen("]", partial(change_rhs_box, "variables", 0, 1))
|
||||
|
||||
# }}}
|
||||
|
||||
@ -1104,8 +1104,8 @@ class DebuggerUI(FrameVarInfoKeeper):
|
||||
self.stack_list.listen("u", move_stack_up)
|
||||
self.stack_list.listen("d", move_stack_down)
|
||||
|
||||
self.stack_list.listen("[", partial(change_rhs_box, 'stack', 1, -1))
|
||||
self.stack_list.listen("]", partial(change_rhs_box, 'stack', 1, 1))
|
||||
self.stack_list.listen("[", partial(change_rhs_box, "stack", 1, -1))
|
||||
self.stack_list.listen("]", partial(change_rhs_box, "stack", 1, 1))
|
||||
|
||||
# }}}
|
||||
|
||||
@ -1237,8 +1237,8 @@ class DebuggerUI(FrameVarInfoKeeper):
|
||||
self.bp_list.listen("b", enable_disable_breakpoint)
|
||||
self.bp_list.listen("H", move_stack_top)
|
||||
|
||||
self.bp_list.listen("[", partial(change_rhs_box, 'breakpoints', 2, -1))
|
||||
self.bp_list.listen("]", partial(change_rhs_box, 'breakpoints', 2, 1))
|
||||
self.bp_list.listen("[", partial(change_rhs_box, "breakpoints", 2, -1))
|
||||
self.bp_list.listen("]", partial(change_rhs_box, "breakpoints", 2, 1))
|
||||
|
||||
# }}}
|
||||
|
||||
@ -1684,10 +1684,10 @@ class DebuggerUI(FrameVarInfoKeeper):
|
||||
# Don't use cmdline_get_namespace() here in Python 2, as it
|
||||
# breaks things (issue #166).
|
||||
if PY3:
|
||||
eval(compile(cmd, "<pudb command line>", 'single'),
|
||||
eval(compile(cmd, "<pudb command line>", "single"),
|
||||
cmdline_get_namespace())
|
||||
else:
|
||||
eval(compile(cmd, "<pudb command line>", 'single'),
|
||||
eval(compile(cmd, "<pudb command line>", "single"),
|
||||
self.debugger.curframe.f_globals,
|
||||
self.debugger.curframe.f_locals)
|
||||
except Exception:
|
||||
@ -1947,7 +1947,7 @@ class DebuggerUI(FrameVarInfoKeeper):
|
||||
print("Falling back to classic shell")
|
||||
runner = shell.run_classic_shell
|
||||
else:
|
||||
runner = shell.custom_shell_dict['pudb_shell']
|
||||
runner = shell.custom_shell_dict["pudb_shell"]
|
||||
|
||||
runner(curframe.f_globals, curframe.f_locals)
|
||||
|
||||
@ -2042,7 +2042,7 @@ class DebuggerUI(FrameVarInfoKeeper):
|
||||
# https://github.com/inducer/pudb/issues/78
|
||||
pass
|
||||
else:
|
||||
color_support = curses.tigetnum('colors')
|
||||
color_support = curses.tigetnum("colors")
|
||||
|
||||
if color_support == 256 and isinstance(self.screen, RawScreen):
|
||||
self.screen.set_terminal_properties(256)
|
||||
@ -2181,8 +2181,8 @@ class DebuggerUI(FrameVarInfoKeeper):
|
||||
w = urwid.Overlay(w, self.top,
|
||||
align="center",
|
||||
valign="middle",
|
||||
width=('relative', 75),
|
||||
height=('relative', 75),
|
||||
width=("relative", 75),
|
||||
height=("relative", 75),
|
||||
)
|
||||
w = Attr(w, "background")
|
||||
|
||||
@ -2617,9 +2617,9 @@ class DebuggerUI(FrameVarInfoKeeper):
|
||||
class_name = frame.f_locals["self"].__class__.__name__
|
||||
except Exception:
|
||||
from pudb.lowlevel import ui_log
|
||||
message = 'Failed to determine class name'
|
||||
message = "Failed to determine class name"
|
||||
ui_log.exception(message)
|
||||
class_name = '!! %s !!' % message
|
||||
class_name = "!! %s !!" % message
|
||||
|
||||
return StackFrame(frame is self.debugger.curframe,
|
||||
code.co_name, class_name,
|
||||
|
@ -45,8 +45,8 @@ def debugger(self, force=False):
|
||||
if not (force or self.call_pdb):
|
||||
return
|
||||
|
||||
if not hasattr(sys, 'last_traceback'):
|
||||
error('No traceback has been produced, nothing to debug.')
|
||||
if not hasattr(sys, "last_traceback"):
|
||||
error("No traceback has been produced, nothing to debug.")
|
||||
return
|
||||
|
||||
from pudb import pm
|
||||
|
@ -39,9 +39,9 @@ def getlogfile():
|
||||
|
||||
def setlogfile(destfile):
|
||||
logfile[0] = destfile
|
||||
with open(destfile, 'a') as openfile:
|
||||
with open(destfile, "a") as openfile:
|
||||
openfile.write(
|
||||
'\n*** Pudb session error log started at {date} ***\n'.format(
|
||||
"\n*** Pudb session error log started at {date} ***\n".format(
|
||||
date=datetime.now()
|
||||
))
|
||||
|
||||
@ -59,8 +59,8 @@ class TerminalOrStreamHandler(logging.StreamHandler):
|
||||
try:
|
||||
if logfile is not None:
|
||||
message = self.format(record)
|
||||
with open(logfile, 'a') as openfile:
|
||||
openfile.write('\n%s\n' % message)
|
||||
with open(logfile, "a") as openfile:
|
||||
openfile.write("\n%s\n" % message)
|
||||
elif _have_debugger():
|
||||
dbg = _get_debugger()
|
||||
message = self.format(record)
|
||||
@ -74,18 +74,18 @@ class TerminalOrStreamHandler(logging.StreamHandler):
|
||||
def _init_loggers():
|
||||
ui_handler = TerminalOrStreamHandler()
|
||||
ui_formatter = logging.Formatter(
|
||||
fmt='*** Pudb UI Exception Encountered: %(message)s ***\n'
|
||||
fmt="*** Pudb UI Exception Encountered: %(message)s ***\n"
|
||||
)
|
||||
ui_handler.setFormatter(ui_formatter)
|
||||
ui_log = logging.getLogger('ui')
|
||||
ui_log = logging.getLogger("ui")
|
||||
ui_log.addHandler(ui_handler)
|
||||
|
||||
settings_handler = TerminalOrStreamHandler()
|
||||
settings_formatter = logging.Formatter(
|
||||
fmt='*** Pudb Settings Exception Encountered: %(message)s ***\n'
|
||||
fmt="*** Pudb Settings Exception Encountered: %(message)s ***\n"
|
||||
)
|
||||
settings_handler.setFormatter(settings_formatter)
|
||||
settings_log = logging.getLogger('settings')
|
||||
settings_log = logging.getLogger("settings")
|
||||
settings_log.addHandler(settings_handler)
|
||||
|
||||
return ui_log, settings_log
|
||||
@ -178,8 +178,8 @@ def lookup_module(filename):
|
||||
if os.path.exists(f): # and self.canonic(f) == self.mainpyfile:
|
||||
return f
|
||||
root, ext = os.path.splitext(filename)
|
||||
if ext == '':
|
||||
filename = filename + '.py'
|
||||
if ext == "":
|
||||
filename = filename + ".py"
|
||||
if os.path.isabs(filename):
|
||||
return filename
|
||||
for dirname in sys.path:
|
||||
@ -224,14 +224,14 @@ def detect_encoding(line_iter):
|
||||
try:
|
||||
return next(line_iter)
|
||||
except StopIteration:
|
||||
return ''
|
||||
return ""
|
||||
|
||||
def find_cookie(line):
|
||||
try:
|
||||
if PY3:
|
||||
line_string = line
|
||||
else:
|
||||
line_string = line.decode('ascii')
|
||||
line_string = line.decode("ascii")
|
||||
except UnicodeDecodeError:
|
||||
return None
|
||||
|
||||
@ -245,9 +245,9 @@ def detect_encoding(line_iter):
|
||||
# This behaviour mimics the Python interpreter
|
||||
raise SyntaxError("unknown encoding: " + encoding)
|
||||
|
||||
if bom_found and codec.name != 'utf-8':
|
||||
if bom_found and codec.name != "utf-8":
|
||||
# This behaviour mimics the Python interpreter
|
||||
raise SyntaxError('encoding problem: utf-8')
|
||||
raise SyntaxError("encoding problem: utf-8")
|
||||
return encoding
|
||||
|
||||
first = read_or_stop()
|
||||
@ -258,7 +258,7 @@ def detect_encoding(line_iter):
|
||||
bom_found = True
|
||||
first = first[3:]
|
||||
if not first:
|
||||
return 'utf-8', []
|
||||
return "utf-8", []
|
||||
|
||||
encoding = find_cookie(first)
|
||||
if encoding:
|
||||
@ -266,13 +266,13 @@ def detect_encoding(line_iter):
|
||||
|
||||
second = read_or_stop()
|
||||
if not second:
|
||||
return 'utf-8', [first]
|
||||
return "utf-8", [first]
|
||||
|
||||
encoding = find_cookie(second)
|
||||
if encoding:
|
||||
return encoding, [first, second]
|
||||
|
||||
return 'utf-8', [first, second]
|
||||
return "utf-8", [first, second]
|
||||
|
||||
|
||||
def decode_lines(lines):
|
||||
|
@ -10,7 +10,7 @@ if PY3:
|
||||
text_type = str
|
||||
|
||||
def execfile(fname, globs, locs=None):
|
||||
exec(compile(open(fname).read(), fname, 'exec'), globs, locs or globs)
|
||||
exec(compile(open(fname).read(), fname, "exec"), globs, locs or globs)
|
||||
else:
|
||||
raw_input = raw_input
|
||||
xrange = xrange
|
||||
|
@ -41,18 +41,18 @@ import struct
|
||||
|
||||
from pudb.debugger import Debugger
|
||||
|
||||
__all__ = ['PUDB_RDB_HOST', 'PUDB_RDB_PORT', 'default_port',
|
||||
'debugger', 'set_trace']
|
||||
__all__ = ["PUDB_RDB_HOST", "PUDB_RDB_PORT", "default_port",
|
||||
"debugger", "set_trace"]
|
||||
|
||||
default_port = 6899
|
||||
|
||||
PUDB_RDB_HOST = os.environ.get('PUDB_RDB_HOST') or '127.0.0.1'
|
||||
PUDB_RDB_PORT = int(os.environ.get('PUDB_RDB_PORT') or default_port)
|
||||
PUDB_RDB_HOST = os.environ.get("PUDB_RDB_HOST") or "127.0.0.1"
|
||||
PUDB_RDB_PORT = int(os.environ.get("PUDB_RDB_PORT") or default_port)
|
||||
|
||||
#: Holds the currently active debugger.
|
||||
_current = [None]
|
||||
|
||||
_frame = getattr(sys, '_getframe')
|
||||
_frame = getattr(sys, "_getframe")
|
||||
|
||||
NO_AVAILABLE_PORT = """\
|
||||
{self.ident}: Couldn't find an available port.
|
||||
@ -65,12 +65,12 @@ BANNER = """\
|
||||
{self.ident}: Waiting for client...
|
||||
"""
|
||||
|
||||
SESSION_STARTED = '{self.ident}: Now in session with {self.remote_addr}.'
|
||||
SESSION_ENDED = '{self.ident}: Session with {self.remote_addr} ended.'
|
||||
SESSION_STARTED = "{self.ident}: Now in session with {self.remote_addr}."
|
||||
SESSION_ENDED = "{self.ident}: Session with {self.remote_addr} ended."
|
||||
|
||||
|
||||
class RemoteDebugger(Debugger):
|
||||
me = 'pudb'
|
||||
me = "pudb"
|
||||
_prev_outs = None
|
||||
_sock = None
|
||||
|
||||
@ -85,14 +85,14 @@ class RemoteDebugger(Debugger):
|
||||
host, port, port_search_limit)
|
||||
self._sock.setblocking(1)
|
||||
self._sock.listen(1)
|
||||
self.ident = '{0}:{1}'.format(self.me, this_port)
|
||||
self.ident = "{0}:{1}".format(self.me, this_port)
|
||||
self.host = host
|
||||
self.port = this_port
|
||||
self.say(BANNER.format(self=self))
|
||||
|
||||
self._client, address = self._sock.accept()
|
||||
self._client.setblocking(1)
|
||||
self.remote_addr = ':'.join(str(v) for v in address)
|
||||
self.remote_addr = ":".join(str(v) for v in address)
|
||||
self.say(SESSION_STARTED.format(self=self))
|
||||
|
||||
# makefile ignores encoding if there's no buffering.
|
||||
@ -187,7 +187,7 @@ def set_trace(frame=None, term_size=None, host=PUDB_RDB_HOST, port=PUDB_RDB_PORT
|
||||
if term_size is None:
|
||||
try:
|
||||
# Getting terminal size
|
||||
s = struct.unpack('hh', fcntl.ioctl(1, termios.TIOCGWINSZ, '1234'))
|
||||
s = struct.unpack("hh", fcntl.ioctl(1, termios.TIOCGWINSZ, "1234"))
|
||||
term_size = (s[1], s[0])
|
||||
except Exception:
|
||||
term_size = (80, 24)
|
||||
|
14
pudb/run.py
14
pudb/run.py
@ -14,15 +14,15 @@ def main():
|
||||
# and makes it possible without much fuss to support cases like:
|
||||
# python -m pudb -m http.server -h
|
||||
# where the -h will be passed to the http.server module
|
||||
parser.add_argument("-m", "--module", action='store_true',
|
||||
parser.add_argument("-m", "--module", action="store_true",
|
||||
help="Debug as module or package instead of as a script")
|
||||
|
||||
parser.add_argument("-le", "--log-errors", nargs=1, metavar='FILE',
|
||||
parser.add_argument("-le", "--log-errors", nargs=1, metavar="FILE",
|
||||
help="Log internal errors to the given file")
|
||||
parser.add_argument("--pre-run", metavar="COMMAND",
|
||||
help="Run command before each program run",
|
||||
default="")
|
||||
parser.add_argument('script_args', nargs=argparse.REMAINDER,
|
||||
parser.add_argument("script_args", nargs=argparse.REMAINDER,
|
||||
help="Arguments to pass to script or module")
|
||||
|
||||
options = parser.parse_args()
|
||||
@ -33,8 +33,8 @@ def main():
|
||||
setlogfile(options.log_errors[0])
|
||||
|
||||
options_kwargs = {
|
||||
'pre_run': options.pre_run,
|
||||
'steal_output': options.steal_output,
|
||||
"pre_run": options.pre_run,
|
||||
"steal_output": options.steal_output,
|
||||
}
|
||||
|
||||
if len(args) < 1:
|
||||
@ -50,12 +50,12 @@ def main():
|
||||
else:
|
||||
from os.path import exists
|
||||
if not exists(mainpyfile):
|
||||
print('Error: %s does not exist' % mainpyfile, file=sys.stderr)
|
||||
print("Error: %s does not exist" % mainpyfile, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
from pudb import runscript
|
||||
runscript(mainpyfile, **options_kwargs)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
@ -34,18 +34,18 @@ from pudb.lowlevel import (lookup_module, get_breakpoint_invalid_reason,
|
||||
|
||||
# minor LGPL violation: stolen from python-xdg
|
||||
|
||||
_home = os.environ.get('HOME', None)
|
||||
xdg_data_home = os.environ.get('XDG_DATA_HOME',
|
||||
os.path.join(_home, '.local', 'share') if _home else None)
|
||||
_home = os.environ.get("HOME", None)
|
||||
xdg_data_home = os.environ.get("XDG_DATA_HOME",
|
||||
os.path.join(_home, ".local", "share") if _home else None)
|
||||
|
||||
|
||||
XDG_CONFIG_HOME = os.environ.get('XDG_CONFIG_HOME',
|
||||
os.path.join(_home, '.config') if _home else None)
|
||||
XDG_CONFIG_HOME = os.environ.get("XDG_CONFIG_HOME",
|
||||
os.path.join(_home, ".config") if _home else None)
|
||||
|
||||
if XDG_CONFIG_HOME:
|
||||
XDG_CONFIG_DIRS = [XDG_CONFIG_HOME]
|
||||
else:
|
||||
XDG_CONFIG_DIRS = os.environ.get('XDG_CONFIG_DIRS', '/etc/xdg').split(':')
|
||||
XDG_CONFIG_DIRS = os.environ.get("XDG_CONFIG_DIRS", "/etc/xdg").split(":")
|
||||
|
||||
|
||||
def get_save_config_path(*resource):
|
||||
@ -54,7 +54,7 @@ def get_save_config_path(*resource):
|
||||
if not resource:
|
||||
resource = [XDG_CONF_RESOURCE]
|
||||
resource = os.path.join(*resource)
|
||||
assert not resource.startswith('/')
|
||||
assert not resource.startswith("/")
|
||||
path = os.path.join(XDG_CONFIG_HOME, resource)
|
||||
if not os.path.isdir(path):
|
||||
os.makedirs(path, 448) # 0o700
|
||||
@ -92,7 +92,7 @@ def load_config():
|
||||
if cparser.has_section(CONF_SECTION):
|
||||
conf_dict.update(dict(cparser.items(CONF_SECTION)))
|
||||
except Exception:
|
||||
settings_log.exception('Failed to load config')
|
||||
settings_log.exception("Failed to load config")
|
||||
|
||||
conf_dict.setdefault("shell", "internal")
|
||||
conf_dict.setdefault("theme", "classic")
|
||||
@ -128,7 +128,7 @@ def load_config():
|
||||
else:
|
||||
conf_dict[name] = True
|
||||
except Exception:
|
||||
settings_log.exception('Failed to process config')
|
||||
settings_log.exception("Failed to process config")
|
||||
|
||||
normalize_bool_inplace("line_numbers")
|
||||
normalize_bool_inplace("wrap_variables")
|
||||
@ -156,7 +156,7 @@ def save_config(conf_dict):
|
||||
cparser.write(outf)
|
||||
outf.close()
|
||||
except Exception:
|
||||
settings_log.exception('Failed to save config')
|
||||
settings_log.exception("Failed to save config")
|
||||
|
||||
|
||||
def edit_config(ui, conf_dict):
|
||||
@ -521,14 +521,14 @@ def parse_breakpoints(lines):
|
||||
filename = None
|
||||
lineno = None
|
||||
cond = None
|
||||
comma = arg.find(',')
|
||||
comma = arg.find(",")
|
||||
|
||||
if comma > 0:
|
||||
# parse stuff after comma: "condition"
|
||||
cond = arg[comma+1:].lstrip()
|
||||
arg = arg[:comma].rstrip()
|
||||
|
||||
colon = arg.rfind(':')
|
||||
colon = arg.rfind(":")
|
||||
funcname = None
|
||||
|
||||
if colon > 0:
|
||||
@ -597,7 +597,7 @@ def save_breakpoints(bp_list):
|
||||
if not save_path:
|
||||
return
|
||||
|
||||
histfile = open(get_breakpoints_file_name(), 'w')
|
||||
histfile = open(get_breakpoints_file_name(), "w")
|
||||
bp_list = set([(bp.file, bp.line, bp.cond) for bp in bp_list])
|
||||
for bp in bp_list:
|
||||
line = "b %s:%d" % (bp[0], bp[1])
|
||||
|
@ -145,7 +145,7 @@ def ipython_version():
|
||||
|
||||
|
||||
def run_ipython_shell_v10(globals, locals, first_time=[True]):
|
||||
'''IPython shell from IPython version 0.10'''
|
||||
"""IPython shell from IPython version 0.10"""
|
||||
if first_time:
|
||||
banner = "Hit Ctrl-D to return to PuDB."
|
||||
first_time.pop()
|
||||
@ -161,7 +161,7 @@ def run_ipython_shell_v10(globals, locals, first_time=[True]):
|
||||
|
||||
|
||||
def _update_ipython_ns(shell, globals, locals):
|
||||
'''Update the IPython 0.11 namespace at every visit'''
|
||||
"""Update the IPython 0.11 namespace at every visit"""
|
||||
|
||||
shell.user_ns = locals.copy()
|
||||
|
||||
@ -169,7 +169,7 @@ def _update_ipython_ns(shell, globals, locals):
|
||||
shell.user_global_ns = globals
|
||||
except AttributeError:
|
||||
class DummyMod(object):
|
||||
"A dummy module used for IPython's interactive namespace."
|
||||
"""A dummy module used for IPython's interactive namespace."""
|
||||
pass
|
||||
|
||||
user_module = DummyMod()
|
||||
@ -181,7 +181,7 @@ def _update_ipython_ns(shell, globals, locals):
|
||||
|
||||
|
||||
def run_ipython_shell_v11(globals, locals, first_time=[True]):
|
||||
'''IPython shell from IPython version 0.11'''
|
||||
"""IPython shell from IPython version 0.11"""
|
||||
if first_time:
|
||||
banner = "Hit Ctrl-D to return to PuDB."
|
||||
first_time.pop()
|
||||
@ -226,7 +226,7 @@ def run_ipython_shell_v11(globals, locals, first_time=[True]):
|
||||
|
||||
def run_ipython_shell(globals, locals):
|
||||
import IPython
|
||||
if have_ipython() and hasattr(IPython, 'Shell'):
|
||||
if have_ipython() and hasattr(IPython, "Shell"):
|
||||
return run_ipython_shell_v10(globals, locals)
|
||||
else:
|
||||
return run_ipython_shell_v11(globals, locals)
|
||||
@ -237,7 +237,7 @@ def run_ipython_shell(globals, locals):
|
||||
def run_ptpython_shell(globals, locals):
|
||||
# Use the default ptpython history
|
||||
import os
|
||||
history_filename = os.path.expanduser('~/.ptpython/history')
|
||||
history_filename = os.path.expanduser("~/.ptpython/history")
|
||||
ptpython_embed(globals=globals.copy(), locals=locals.copy(),
|
||||
history_filename=history_filename,
|
||||
configure=run_config)
|
||||
@ -247,7 +247,7 @@ def run_ptipython_shell(globals, locals):
|
||||
# Use the default ptpython history
|
||||
import os
|
||||
|
||||
history_filename = os.path.expanduser('~/.ptpython/history')
|
||||
history_filename = os.path.expanduser("~/.ptpython/history")
|
||||
ptipython_embed(globals=globals.copy(), locals=locals.copy(),
|
||||
history_filename=history_filename,
|
||||
configure=run_config)
|
||||
|
@ -33,7 +33,7 @@ TABSTOP = 8
|
||||
|
||||
|
||||
class SourceLine(urwid.FlowWidget):
|
||||
def __init__(self, dbg_ui, text, line_nr='', attr=None, has_breakpoint=False):
|
||||
def __init__(self, dbg_ui, text, line_nr="", attr=None, has_breakpoint=False):
|
||||
self.dbg_ui = dbg_ui
|
||||
self.text = text
|
||||
self.attr = attr
|
||||
@ -67,7 +67,7 @@ class SourceLine(urwid.FlowWidget):
|
||||
maxcol = size[0]
|
||||
hscroll = self.dbg_ui.source_hscroll_start
|
||||
|
||||
# attrs is a list of words like 'focused' and 'breakpoint'
|
||||
# attrs is a list of words like "focused" and "breakpoint"
|
||||
attrs = []
|
||||
|
||||
if self.is_current:
|
||||
@ -195,7 +195,7 @@ def format_source(debugger_ui, lines, breakpoints):
|
||||
t.Keyword.Namespace: "namespace",
|
||||
t.Token.Argument: "argument",
|
||||
t.Token.Dunder: "dunder",
|
||||
t.Token.Keyword2: 'keyword2',
|
||||
t.Token.Keyword2: "keyword2",
|
||||
t.Keyword: "keyword",
|
||||
t.Literal: "literal",
|
||||
t.Name.Exception: "exception",
|
||||
@ -219,20 +219,20 @@ def format_source(debugger_ui, lines, breakpoints):
|
||||
# associated strings to new token types.
|
||||
ATTR_TRANSLATE = { # noqa: N806
|
||||
t.Keyword: {
|
||||
'class': t.Token.Keyword2,
|
||||
'def': t.Token.Keyword2,
|
||||
'exec': t.Token.Keyword2,
|
||||
'lambda': t.Token.Keyword2,
|
||||
'print': t.Token.Keyword2,
|
||||
"class": t.Token.Keyword2,
|
||||
"def": t.Token.Keyword2,
|
||||
"exec": t.Token.Keyword2,
|
||||
"lambda": t.Token.Keyword2,
|
||||
"print": t.Token.Keyword2,
|
||||
},
|
||||
t.Operator: {
|
||||
'.': t.Token,
|
||||
".": t.Token,
|
||||
},
|
||||
t.Name.Builtin.Pseudo: {
|
||||
'self': t.Token,
|
||||
"self": t.Token,
|
||||
},
|
||||
t.Name.Builtin: {
|
||||
'object': t.Name.Class,
|
||||
"object": t.Name.Class,
|
||||
},
|
||||
}
|
||||
|
||||
@ -262,7 +262,7 @@ def format_source(debugger_ui, lines, breakpoints):
|
||||
# Translate dunder method tokens
|
||||
if ttype == (
|
||||
t.Name.Function
|
||||
and s.startswith('__') and s.endswith('__')
|
||||
and s.startswith("__") and s.endswith("__")
|
||||
):
|
||||
ttype = t.Token.Dunder
|
||||
|
||||
@ -310,14 +310,14 @@ def format_source(debugger_ui, lines, breakpoints):
|
||||
|
||||
|
||||
class ParseState(object):
|
||||
'''States for the ArgumentParser class'''
|
||||
"""States for the ArgumentParser class"""
|
||||
idle = 1
|
||||
found_function = 2
|
||||
found_open_paren = 3
|
||||
|
||||
|
||||
class ArgumentParser(object):
|
||||
'''Parse source code tokens and identify function arguments.
|
||||
"""Parse source code tokens and identify function arguments.
|
||||
|
||||
This parser implements a state machine which accepts
|
||||
Pygments tokens, delivered sequentially from the beginning
|
||||
@ -329,7 +329,7 @@ class ArgumentParser(object):
|
||||
argument, it returns the correct token type for that
|
||||
item (the caller should then replace the associated item's
|
||||
token type with the returned type)
|
||||
'''
|
||||
"""
|
||||
|
||||
def __init__(self, pygments_token):
|
||||
self.t = pygments_token
|
||||
@ -337,22 +337,22 @@ class ArgumentParser(object):
|
||||
self.paren_level = 0
|
||||
|
||||
def parse_token(self, token, s):
|
||||
'''Parse token. Return None or replacement token type'''
|
||||
"""Parse token. Return None or replacement token type"""
|
||||
if self.state == ParseState.idle:
|
||||
if token is self.t.Name.Function:
|
||||
self.state = ParseState.found_function
|
||||
self.paren_level = 0
|
||||
elif self.state == ParseState.found_function:
|
||||
if token is self.t.Punctuation and s == '(':
|
||||
if token is self.t.Punctuation and s == "(":
|
||||
self.state = ParseState.found_open_paren
|
||||
self.paren_level = 1
|
||||
else:
|
||||
if ((token is self.t.Name)
|
||||
or (token is self.t.Name.Builtin.Pseudo and s == 'self')):
|
||||
or (token is self.t.Name.Builtin.Pseudo and s == "self")):
|
||||
return self.t.Token.Argument
|
||||
elif token is self.t.Punctuation and s == ')':
|
||||
elif token is self.t.Punctuation and s == ")":
|
||||
self.paren_level -= 1
|
||||
elif token is self.t.Punctuation and s == '(':
|
||||
elif token is self.t.Punctuation and s == "(":
|
||||
self.paren_level += 1
|
||||
if self.paren_level == 0:
|
||||
self.state = ParseState.idle
|
||||
|
@ -1024,9 +1024,9 @@ def get_palette(may_use_fancy_formats, theme="classic"):
|
||||
|
||||
# Convert hNNN syntax to equivalent #RGB value
|
||||
# (https://github.com/wardi/urwid/issues/24)
|
||||
if fg_color.startswith('h') or bg_color.startswith('h'):
|
||||
if fg_color.startswith("h") or bg_color.startswith("h"):
|
||||
attr = urwid.AttrSpec(fg_color, bg_color, colors=256)
|
||||
palette_list.append((setting_name, 'default', 'default', 'default',
|
||||
palette_list.append((setting_name, "default", "default", "default",
|
||||
attr.foreground,
|
||||
attr.background))
|
||||
else:
|
||||
|
@ -195,7 +195,7 @@ class BreakpointFrame(urwid.FlowWidget):
|
||||
else:
|
||||
apfx = ""
|
||||
|
||||
bp_pfx = ''
|
||||
bp_pfx = ""
|
||||
if not self.enabled:
|
||||
apfx += "disabled "
|
||||
bp_pfx += "X"
|
||||
@ -204,7 +204,7 @@ class BreakpointFrame(urwid.FlowWidget):
|
||||
bp_pfx += ">>"
|
||||
bp_pfx = bp_pfx.ljust(3)
|
||||
|
||||
hits_label = 'hits' if self.hits != 1 else 'hit'
|
||||
hits_label = "hits" if self.hits != 1 else "hit"
|
||||
loc = " %s:%d (%s %s)" % (self.filename, self.line, self.hits, hits_label)
|
||||
text = bp_pfx+loc
|
||||
attr = [(apfx+"breakpoint", len(loc))]
|
||||
|
@ -41,12 +41,10 @@ try:
|
||||
except ImportError:
|
||||
HAVE_NUMPY = 0
|
||||
|
||||
from pudb.py3compat import PY3, execfile, raw_input, xrange, \
|
||||
from pudb.py3compat import execfile, raw_input, xrange, \
|
||||
integer_types, string_types, text_type
|
||||
if PY3:
|
||||
ELLIPSIS = '…'
|
||||
else:
|
||||
ELLIPSIS = unicode('…', 'utf-8') # noqa: F821
|
||||
|
||||
ELLIPSIS = "…"
|
||||
|
||||
from pudb.ui_tools import text_width
|
||||
|
||||
@ -137,7 +135,7 @@ class VariableWidget(urwid.FlowWidget):
|
||||
self.wrap = iinfo.wrap
|
||||
|
||||
def __str__(self):
|
||||
return ('VariableWidget: {value_str}, level {nesting_level}, at {id_path}'
|
||||
return ("VariableWidget: {value_str}, level {nesting_level}, at {id_path}"
|
||||
.format(
|
||||
value_str=self.value_str,
|
||||
nesting_level=self.nesting_level,
|
||||
@ -151,8 +149,8 @@ class VariableWidget(urwid.FlowWidget):
|
||||
|
||||
def _get_text(self, size):
|
||||
maxcol = size[0] - len(self.prefix) # self.prefix is a padding
|
||||
var_label = self.var_label or ''
|
||||
value_str = self.value_str or ''
|
||||
var_label = self.var_label or ""
|
||||
value_str = self.value_str or ""
|
||||
alltext = var_label + ": " + value_str
|
||||
# The first line is not indented
|
||||
firstline = self.prefix + alltext[:maxcol]
|
||||
@ -183,7 +181,7 @@ class VariableWidget(urwid.FlowWidget):
|
||||
else:
|
||||
apfx = self.attr_prefix+" "
|
||||
|
||||
var_label = self.var_label or ''
|
||||
var_label = self.var_label or ""
|
||||
|
||||
if self.wrap:
|
||||
text = self._get_text(size)
|
||||
@ -287,9 +285,9 @@ def type_stringifier(value):
|
||||
try:
|
||||
return text_type(value)
|
||||
except Exception:
|
||||
message = 'string safe type stringifier failed'
|
||||
message = "string safe type stringifier failed"
|
||||
ui_log.exception(message)
|
||||
return '!! %s !!' % message
|
||||
return "!! %s !!" % message
|
||||
|
||||
elif hasattr(type(value), "safely_stringify_for_pudb"):
|
||||
try:
|
||||
@ -297,9 +295,9 @@ def type_stringifier(value):
|
||||
# and return nonsense.
|
||||
result = value.safely_stringify_for_pudb()
|
||||
except Exception:
|
||||
message = 'safely_stringify_for_pudb call failed'
|
||||
message = "safely_stringify_for_pudb call failed"
|
||||
ui_log.exception(message)
|
||||
result = '!! %s !!' % message
|
||||
result = "!! %s !!" % message
|
||||
|
||||
if isinstance(result, string_types):
|
||||
return text_type(result)
|
||||
@ -316,17 +314,9 @@ def get_stringifier(iinfo):
|
||||
if iinfo.display_type == "type":
|
||||
return type_stringifier
|
||||
elif iinfo.display_type == "repr":
|
||||
if PY3:
|
||||
return repr
|
||||
else:
|
||||
return lambda value: repr(value).decode("utf-8")
|
||||
return repr
|
||||
elif iinfo.display_type == "str":
|
||||
if PY3:
|
||||
return str
|
||||
else:
|
||||
return lambda value: (
|
||||
value.decode("utf-8") if isinstance(value, bytes)
|
||||
else text_type(value))
|
||||
return str
|
||||
else:
|
||||
try:
|
||||
if not custom_stringifier_dict: # Only execfile once
|
||||
@ -377,7 +367,7 @@ class ValueWalker:
|
||||
# repr() on a random object.
|
||||
displayed_value = type_stringifier(value) \
|
||||
+ " (!! %s error !!)" % iinfo.display_type
|
||||
ui_log.exception('stringifier failed')
|
||||
ui_log.exception("stringifier failed")
|
||||
|
||||
if iinfo.show_detail:
|
||||
if iinfo.access_level == "public":
|
||||
@ -417,15 +407,12 @@ class ValueWalker:
|
||||
key_it = None
|
||||
|
||||
try:
|
||||
if PY3:
|
||||
key_it = value.keys()
|
||||
else:
|
||||
key_it = value.iterkeys()
|
||||
key_it = value.keys()
|
||||
except AttributeError:
|
||||
# keys or iterkeys doesn't exist, not worth mentioning!
|
||||
pass
|
||||
except Exception:
|
||||
ui_log.exception('Failed to obtain key iterator')
|
||||
ui_log.exception("Failed to obtain key iterator")
|
||||
|
||||
if key_it is None:
|
||||
try:
|
||||
@ -434,14 +421,14 @@ class ValueWalker:
|
||||
# no __len__ defined on the value, not worth mentioning!
|
||||
pass
|
||||
except Exception:
|
||||
ui_log.exception('Failed to determine container length')
|
||||
ui_log.exception("Failed to determine container length")
|
||||
else:
|
||||
try:
|
||||
value[0]
|
||||
except IndexError:
|
||||
key_it = []
|
||||
except Exception:
|
||||
ui_log.exception('Item is not iterable')
|
||||
ui_log.exception("Item is not iterable")
|
||||
else:
|
||||
key_it = xrange(len_value)
|
||||
|
||||
@ -469,7 +456,7 @@ class ValueWalker:
|
||||
try:
|
||||
key_its.append(dir(value))
|
||||
except Exception:
|
||||
ui_log.exception('Failed to look up attributes')
|
||||
ui_log.exception("Failed to look up attributes")
|
||||
|
||||
keys = [key
|
||||
for ki in key_its
|
||||
@ -608,7 +595,7 @@ def make_var_view(frame_var_info, locals, globals):
|
||||
attr_prefix="return")
|
||||
|
||||
for var in vars:
|
||||
if not (var.startswith('__') and var.endswith('__')):
|
||||
if not (var.startswith("__") and var.endswith("__")):
|
||||
tmv_walker.walk_value(None, var, locals[var])
|
||||
|
||||
result = tmv_walker.main_widget_list
|
||||
|
@ -1,5 +1,10 @@
|
||||
[flake8]
|
||||
ignore = E126,E127,E128,E123,E226,E241,E242,E265,W503,E402
|
||||
max-line-length=85
|
||||
|
||||
inline-quotes = "
|
||||
docstring-quotes = """
|
||||
multiline-quotes = """
|
||||
|
||||
[wheel]
|
||||
universal = 0
|
||||
|
@ -4,34 +4,34 @@ from pudb.py3compat import PY3
|
||||
|
||||
|
||||
def test_detect_encoding_nocookie():
|
||||
lines = [u'Test Проверка']
|
||||
lines = [line.encode('utf-8') for line in lines]
|
||||
lines = [u"Test Проверка"]
|
||||
lines = [line.encode("utf-8") for line in lines]
|
||||
encoding, _ = detect_encoding(iter(lines))
|
||||
assert encoding == 'utf-8'
|
||||
assert encoding == "utf-8"
|
||||
|
||||
|
||||
def test_detect_encoding_cookie():
|
||||
lines = [
|
||||
u'# coding=utf-8',
|
||||
u'Test',
|
||||
u'Проверка'
|
||||
u"# coding=utf-8",
|
||||
u"Test",
|
||||
u"Проверка"
|
||||
]
|
||||
lines = [line.encode('utf-8') for line in lines]
|
||||
lines = [line.encode("utf-8") for line in lines]
|
||||
encoding, _ = detect_encoding(iter(lines))
|
||||
assert encoding == 'utf-8'
|
||||
assert encoding == "utf-8"
|
||||
|
||||
|
||||
def test_decode_lines():
|
||||
unicode_lines = [
|
||||
u'# coding=utf-8',
|
||||
u'Test',
|
||||
u'Проверка',
|
||||
u"# coding=utf-8",
|
||||
u"Test",
|
||||
u"Проверка",
|
||||
]
|
||||
lines = [line.encode('utf-8') for line in unicode_lines]
|
||||
lines = [line.encode("utf-8") for line in unicode_lines]
|
||||
if PY3:
|
||||
assert unicode_lines == list(decode_lines(iter(lines)))
|
||||
else:
|
||||
assert [line.decode('utf-8')
|
||||
assert [line.decode("utf-8")
|
||||
for line in lines] == list(decode_lines(iter(lines)))
|
||||
|
||||
|
||||
|
@ -4,63 +4,63 @@ from pudb.ui_tools import make_canvas
|
||||
|
||||
|
||||
def test_simple():
|
||||
text = u'aaaaaa'
|
||||
text = u"aaaaaa"
|
||||
canvas = make_canvas(
|
||||
txt=[text],
|
||||
attr=[[('var value', len(text))]],
|
||||
attr=[[("var value", len(text))]],
|
||||
maxcol=len(text) + 5
|
||||
)
|
||||
content = list(canvas.content())
|
||||
assert content == [
|
||||
[('var value', None, b'aaaaaa'), (None, None, b' ' * 5)]
|
||||
[("var value", None, b"aaaaaa"), (None, None, b" " * 5)]
|
||||
]
|
||||
|
||||
|
||||
def test_multiple():
|
||||
canvas = make_canvas(
|
||||
txt=[u'Return: None'],
|
||||
attr=[[('return label', 8), ('return value', 4)]],
|
||||
txt=[u"Return: None"],
|
||||
attr=[[("return label", 8), ("return value", 4)]],
|
||||
maxcol=100
|
||||
)
|
||||
content = list(canvas.content())
|
||||
assert content == [
|
||||
[('return label', None, b'Return: '),
|
||||
('return value', None, b'None'),
|
||||
(None, None, b' ' * 88)]
|
||||
[("return label", None, b"Return: "),
|
||||
("return value", None, b"None"),
|
||||
(None, None, b" " * 88)]
|
||||
]
|
||||
|
||||
|
||||
def test_boundary():
|
||||
text = u'aaaaaa'
|
||||
text = u"aaaaaa"
|
||||
canvas = make_canvas(
|
||||
txt=[text],
|
||||
attr=[[('var value', len(text))]],
|
||||
attr=[[("var value", len(text))]],
|
||||
maxcol=len(text)
|
||||
)
|
||||
assert list(canvas.content()) == [[('var value', None, b'aaaaaa')]]
|
||||
assert list(canvas.content()) == [[("var value", None, b"aaaaaa")]]
|
||||
|
||||
|
||||
def test_byte_boundary():
|
||||
text = u'aaaaaaé'
|
||||
text = u"aaaaaaé"
|
||||
canvas = make_canvas(
|
||||
txt=[text],
|
||||
attr=[[('var value', len(text))]],
|
||||
attr=[[("var value", len(text))]],
|
||||
maxcol=len(text)
|
||||
)
|
||||
assert list(canvas.content()) == [[('var value', None, b'aaaaaa\xc3\xa9')]]
|
||||
assert list(canvas.content()) == [[("var value", None, b"aaaaaa\xc3\xa9")]]
|
||||
|
||||
|
||||
def test_wide_chars():
|
||||
text = u"data: '中文'"
|
||||
canvas = make_canvas(
|
||||
txt=[text],
|
||||
attr=[[('var label', 6), ('var value', 4)]],
|
||||
attr=[[("var label", 6), ("var value", 4)]],
|
||||
maxcol=47,
|
||||
)
|
||||
assert list(canvas.content()) == [[
|
||||
('var label', None, b'data: '),
|
||||
('var value', None, u"'中文'".encode('utf-8')),
|
||||
(None, None, b' '*(47 - 12)), # 10 chars, 2 of which are double width
|
||||
("var label", None, b"data: "),
|
||||
("var value", None, u"'中文'".encode("utf-8")),
|
||||
(None, None, b" "*(47 - 12)), # 10 chars, 2 of which are double width
|
||||
]]
|
||||
|
||||
|
||||
|
@ -7,28 +7,28 @@ from pudb.settings import load_breakpoints, save_breakpoints
|
||||
|
||||
|
||||
def test_load_breakpoints(mocker):
|
||||
fake_data = ['b /home/user/test.py:41'], ['b /home/user/test.py:50']
|
||||
fake_data = ["b /home/user/test.py:41"], ["b /home/user/test.py:50"]
|
||||
mock_open = mocker.mock_open()
|
||||
mock_open.return_value.readlines.side_effect = fake_data
|
||||
mocker.patch.object(builtins, 'open', mock_open)
|
||||
mocker.patch('pudb.settings.lookup_module',
|
||||
mocker.Mock(return_value='/home/user/test.py'))
|
||||
mocker.patch('pudb.settings.get_breakpoint_invalid_reason',
|
||||
mocker.patch.object(builtins, "open", mock_open)
|
||||
mocker.patch("pudb.settings.lookup_module",
|
||||
mocker.Mock(return_value="/home/user/test.py"))
|
||||
mocker.patch("pudb.settings.get_breakpoint_invalid_reason",
|
||||
mocker.Mock(return_value=None))
|
||||
result = load_breakpoints()
|
||||
expected = [('/home/user/test.py', 41, False, None, None),
|
||||
('/home/user/test.py', 50, False, None, None)]
|
||||
expected = [("/home/user/test.py", 41, False, None, None),
|
||||
("/home/user/test.py", 50, False, None, None)]
|
||||
assert result == expected
|
||||
|
||||
|
||||
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'))
|
||||
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)
|
||||
mocker.patch.object(builtins, "open", mock_open)
|
||||
|
||||
save_breakpoints(mock_breakpoints)
|
||||
mock_open.assert_called_with('saved-breakpoints', 'w')
|
||||
mock_open.assert_called_with("saved-breakpoints", "w")
|
||||
|
@ -16,14 +16,14 @@ class TestNullSourceCodeProvider:
|
||||
class TestFileSourceCodeProvider:
|
||||
def test_string_file_name(self, mocker):
|
||||
mock_debugger = mocker.Mock()
|
||||
mock_debugger.canonic = mocker.Mock(return_value='<string>')
|
||||
provider = FileSourceCodeProvider(mock_debugger, 'test file name')
|
||||
mock_debugger.canonic = mocker.Mock(return_value="<string>")
|
||||
provider = FileSourceCodeProvider(mock_debugger, "test file name")
|
||||
result = provider.get_lines(mocker.MagicMock())
|
||||
assert len(result) == 1
|
||||
assert isinstance(result[0], SourceLine)
|
||||
|
||||
def test_get_lines(self, mocker):
|
||||
provider = FileSourceCodeProvider(mocker.Mock(), 'test file name')
|
||||
provider = FileSourceCodeProvider(mocker.Mock(), "test file name")
|
||||
result = provider.get_lines(mocker.MagicMock())
|
||||
assert len(result) == 1
|
||||
assert isinstance(result[0], SourceLine)
|
||||
@ -31,7 +31,7 @@ class TestFileSourceCodeProvider:
|
||||
|
||||
class TestDirectSourceCodeProvider:
|
||||
def test_get_lines(self, mocker):
|
||||
provider = DirectSourceCodeProvider(mocker.Mock(), 'test code')
|
||||
provider = DirectSourceCodeProvider(mocker.Mock(), "test code")
|
||||
result = provider.get_lines(mocker.Mock())
|
||||
assert len(result) == 1
|
||||
assert isinstance(result[0], SourceLine)
|
||||
|
@ -21,8 +21,8 @@ def test_get_stringifier():
|
||||
numpy_values = [np.float32(5), np.zeros(5)]
|
||||
|
||||
for value in [
|
||||
A, A2, A(), A2(), u"lól".encode('utf8'), u"lól",
|
||||
1233123, [u"lól".encode('utf8'), u"lól"],
|
||||
A, A2, A(), A2(), u"lól".encode("utf8"), u"lól",
|
||||
1233123, [u"lól".encode("utf8"), u"lól"],
|
||||
] + numpy_values:
|
||||
for display_type in ["type", "repr", "str"]:
|
||||
iinfo = InspectInfo()
|
||||
|
@ -1,7 +1,7 @@
|
||||
#! /bin/sh
|
||||
|
||||
if test "$1" = ""; then
|
||||
PYINTERP="python"
|
||||
PYINTERP="python3"
|
||||
else
|
||||
PYINTERP="$1"
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user