Skip to content

Commit

Permalink
Increase python test coveragec
Browse files Browse the repository at this point in the history
  • Loading branch information
galaunay committed Oct 4, 2020
1 parent 09a269d commit a418dc0
Show file tree
Hide file tree
Showing 11 changed files with 218 additions and 496 deletions.
4 changes: 2 additions & 2 deletions elpy/blackutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# (see https://github.com/jorgenschaefer/elpy/issues/1674).
try:
from pkg_resources import parse_version
except ImportError:
except ImportError: # pragma: no cover
def parse_version(*arg, **kwargs):
raise Fault("`pkg_resources` could not be imported, "
"please reinstall Elpy RPC virtualenv with"
Expand All @@ -26,7 +26,7 @@ def parse_version(*arg, **kwargs):
BLACK_NOT_SUPPORTED = sys.version_info < (3, 6)

try:
if BLACK_NOT_SUPPORTED:
if BLACK_NOT_SUPPORTED: # pragma: no cover
black = None
else:
import black
Expand Down
30 changes: 15 additions & 15 deletions elpy/jedibackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# (see https://github.com/jorgenschaefer/elpy/issues/1674).
try:
from pkg_resources import parse_version
except ImportError:
except ImportError: # pragma: no cover
def parse_version(*arg, **kwargs):
raise Fault("`pkg_resources` could not be imported, "
"please reinstall Elpy RPC virtualenv with"
Expand All @@ -46,7 +46,7 @@ def __init__(self, project_root, environment_binaries_path):
self.completions = {}
sys.path.append(project_root)
# Backward compatibility to jedi<17
if not JEDISUP17:
if not JEDISUP17: # pragma: no cover
self.rpc_get_completions = self.rpc_get_completions_jedi16
self.rpc_get_docstring = self.rpc_get_docstring_jedi16
self.rpc_get_definition = self.rpc_get_definition_jedi16
Expand All @@ -62,8 +62,6 @@ def rpc_get_completions(self, filename, source, offset):
path=filename,
environment=self.environment,
fun_kwargs={'line': line, 'column': column})
if proposals is None:
return []
self.completions = dict((proposal.name, proposal)
for proposal in proposals)
return [{'name': proposal.name.rstrip("="),
Expand Down Expand Up @@ -176,11 +174,11 @@ def rpc_get_definition(self, filename, source, offset):
offset = linecol_to_pos(f.read(),
loc.line,
loc.column)
except IOError:
except IOError: # pragma: no cover
return None
return (loc.module_path, offset)

def rpc_get_definition_jedi16(self, filename, source, offset):
def rpc_get_definition_jedi16(self, filename, source, offset): # pragma: no cover
# Backward compatibility to jedi<17
line, column = pos_to_linecol(source, offset)
locations = run_with_debug(jedi, 'goto_definitions',
Expand Down Expand Up @@ -226,7 +224,7 @@ def rpc_get_definition_jedi16(self, filename, source, offset):
def rpc_get_assignment(self, filename, source, offset):
raise Fault("Obsolete since jedi 17.0. Please use 'get_definition'.")

def rpc_get_assignment_jedi16(self, filename, source, offset):
def rpc_get_assignment_jedi16(self, filename, source, offset): # pragma: no cover
# Backward compatibility to jedi<17
line, column = pos_to_linecol(source, offset)
locations = run_with_debug(jedi, 'goto_assignments',
Expand Down Expand Up @@ -271,7 +269,7 @@ def rpc_get_calltip(self, filename, source, offset):
"index": calls[0].index,
"params": params}

def rpc_get_calltip_jedi16(self, filename, source, offset):
def rpc_get_calltip_jedi16(self, filename, source, offset): # pragma: no cover
# Backward compatibility to jedi<17
line, column = pos_to_linecol(source, offset)
calls = run_with_debug(jedi, 'call_signatures',
Expand Down Expand Up @@ -379,7 +377,7 @@ def rpc_get_oneline_docstring(self, filename, source, offset):
return {"name": name,
"doc": onelinedoc}

def rpc_get_oneline_docstring_jedi16(self, filename, source, offset):
def rpc_get_oneline_docstring_jedi16(self, filename, source, offset): # pragma: no cover
"""Return a oneline docstring for the symbol at offset"""
# Backward compatibility to jedi<17
line, column = pos_to_linecol(source, offset)
Expand Down Expand Up @@ -479,7 +477,7 @@ def rpc_get_usages(self, filename, source, offset):
"offset": offset})
return result

def rpc_get_usages_jedi16(self, filename, source, offset):
def rpc_get_usages_jedi16(self, filename, source, offset): # pragma: no cover
"""Return the uses of the symbol at offset.
Returns a list of occurrences of the symbol, as dicts with the
Expand Down Expand Up @@ -531,7 +529,7 @@ def rpc_get_names(self, filename, source, offset):
"offset": offset})
return result

def rpc_get_names_jedi16(self, filename, source, offset):
def rpc_get_names_jedi16(self, filename, source, offset): # pragma: no cover
"""Return the list of possible names"""
# Backward compatibility to jedi<17
names = jedi.api.names(source=source,
Expand All @@ -555,7 +553,7 @@ def rpc_get_names_jedi16(self, filename, source, offset):

def rpc_get_rename_diff(self, filename, source, offset, new_name):
"""Get the diff resulting from renaming the thing at point"""
if not hasattr(jedi.Script, "rename"):
if not hasattr(jedi.Script, "rename"): # pragma: no cover
return {'success': "Not available"}
line, column = pos_to_linecol(source, offset)
ren = run_with_debug(jedi, 'rename', code=source,
Expand All @@ -575,7 +573,7 @@ def rpc_get_rename_diff(self, filename, source, offset, new_name):
def rpc_get_extract_variable_diff(self, filename, source, offset, new_name,
line_beg, line_end, col_beg, col_end):
"""Get the diff resulting from extracting the selected code"""
if not hasattr(jedi.Script, "extract_variable"):
if not hasattr(jedi.Script, "extract_variable"): # pragma: no cover
return {'success': "Not available"}
ren = run_with_debug(jedi, 'extract_variable', code=source,
path=filename,
Expand All @@ -596,7 +594,7 @@ def rpc_get_extract_variable_diff(self, filename, source, offset, new_name,
def rpc_get_extract_function_diff(self, filename, source, offset, new_name,
line_beg, line_end, col_beg, col_end):
"""Get the diff resulting from extracting the selected code"""
if not hasattr(jedi.Script, "extract_function"):
if not hasattr(jedi.Script, "extract_function"): # pragma: no cover
return {'success': "Not available"}
ren = run_with_debug(jedi, 'extract_function', code=source,
path=filename,
Expand All @@ -616,7 +614,7 @@ def rpc_get_extract_function_diff(self, filename, source, offset, new_name,

def rpc_get_inline_diff(self, filename, source, offset):
"""Get the diff resulting from inlining the selected variable"""
if not hasattr(jedi.Script, "inline"):
if not hasattr(jedi.Script, "inline"): # pragma: no cover
return {'success': "Not available"}
line, column = pos_to_linecol(source, offset)
ren = run_with_debug(jedi, 'inline', code=source,
Expand Down Expand Up @@ -684,6 +682,8 @@ def run_with_debug(jedi, name, fun_kwargs={}, *args, **kwargs):
except Exception as e:
if isinstance(e, re_raise):
raise
if isinstance(e, jedi.RefactoringError):
return None
# Bug jedi#485
if (
isinstance(e, ValueError) and
Expand Down

0 comments on commit a418dc0

Please sign in to comment.