forked from VimPlug/jedi
Merge pull request #284 from davidhalter/sith_recording_bug
Sith recording bug
This commit is contained in:
19
sith.py
19
sith.py
@@ -77,6 +77,8 @@ class TestCase(object):
|
|||||||
def __init__(self, operation, path, line, column, traceback=None):
|
def __init__(self, operation, path, line, column, traceback=None):
|
||||||
if operation not in self.operations:
|
if operation not in self.operations:
|
||||||
raise ValueError("%s is not a valid operation" % operation)
|
raise ValueError("%s is not a valid operation" % operation)
|
||||||
|
|
||||||
|
# Set other attributes
|
||||||
self.operation = operation
|
self.operation = operation
|
||||||
self.path = path
|
self.path = path
|
||||||
self.line = line
|
self.line = line
|
||||||
@@ -86,8 +88,8 @@ class TestCase(object):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def from_cache(cls, record):
|
def from_cache(cls, record):
|
||||||
with open(record) as f:
|
with open(record) as f:
|
||||||
dct = json.load(f)
|
args = json.load(f)
|
||||||
return cls(**dct)
|
return cls(*args)
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
'completions', 'goto_assignments', 'goto_definitions', 'usages',
|
'completions', 'goto_assignments', 'goto_definitions', 'usages',
|
||||||
@@ -123,8 +125,9 @@ class TestCase(object):
|
|||||||
except Exception:
|
except Exception:
|
||||||
self.traceback = traceback.format_exc()
|
self.traceback = traceback.format_exc()
|
||||||
if record is not None:
|
if record is not None:
|
||||||
|
call_args = (self.operation, self.path, self.line, self.column, self.traceback)
|
||||||
with open(record, 'w') as f:
|
with open(record, 'w') as f:
|
||||||
json.dump(self.__dict__, f)
|
json.dump(call_args, f)
|
||||||
self.show_errors()
|
self.show_errors()
|
||||||
if debugger:
|
if debugger:
|
||||||
einfo = sys.exc_info()
|
einfo = sys.exc_info()
|
||||||
@@ -172,7 +175,7 @@ class TestCase(object):
|
|||||||
if os.path.abspath(completion.module_path) == os.path.abspath(self.path):
|
if os.path.abspath(completion.module_path) == os.path.abspath(self.path):
|
||||||
self.show_location(completion.line, completion.column)
|
self.show_location(completion.line, completion.column)
|
||||||
|
|
||||||
show_goto_assignments = show_goto_definitions
|
show_goto_assignments = show_goto_definitions
|
||||||
|
|
||||||
def show_errors(self):
|
def show_errors(self):
|
||||||
print(self.traceback)
|
print(self.traceback)
|
||||||
@@ -181,6 +184,7 @@ class TestCase(object):
|
|||||||
"\tline: {line}\n"
|
"\tline: {line}\n"
|
||||||
"\tcolumn: {column}").format(**self.__dict__))
|
"\tcolumn: {column}").format(**self.__dict__))
|
||||||
|
|
||||||
|
|
||||||
def main(arguments):
|
def main(arguments):
|
||||||
debugger = 'pdb' if arguments['--pdb'] else \
|
debugger = 'pdb' if arguments['--pdb'] else \
|
||||||
'ipdb' if arguments['--ipdb'] else \
|
'ipdb' if arguments['--ipdb'] else \
|
||||||
@@ -191,16 +195,17 @@ def main(arguments):
|
|||||||
if arguments['--debug']:
|
if arguments['--debug']:
|
||||||
jedi.set_debug_function()
|
jedi.set_debug_function()
|
||||||
|
|
||||||
if arguments['redo'] or arguments['show']:
|
if arguments['redo'] or arguments['show']:
|
||||||
t = TestCase.from_cache(record)
|
t = TestCase.from_cache(record)
|
||||||
if arguments['show']:
|
if arguments['show']:
|
||||||
t.show_errors()
|
t.show_errors()
|
||||||
else:
|
else:
|
||||||
t.run(debugger)
|
t.run(debugger)
|
||||||
elif arguments['run']:
|
elif arguments['run']:
|
||||||
TestCase(arguments['<operation>'], arguments['<path>'],
|
TestCase(
|
||||||
|
arguments['<operation>'], arguments['<path>'],
|
||||||
int(arguments['<line>']), int(arguments['<column>'])
|
int(arguments['<line>']), int(arguments['<column>'])
|
||||||
).run(debugger, print_result=True)
|
).run(debugger, print_result=True)
|
||||||
else:
|
else:
|
||||||
for _ in range(int(arguments['--maxtries'])):
|
for _ in range(int(arguments['--maxtries'])):
|
||||||
t = TestCase.generate(arguments['<path>'] or '.')
|
t = TestCase.generate(arguments['<path>'] or '.')
|
||||||
|
|||||||
Reference in New Issue
Block a user