Skip to content

Commit

Permalink
Fix python tests
Browse files Browse the repository at this point in the history
  • Loading branch information
galaunay committed Sep 27, 2020
1 parent b0c7ecb commit 990fb58
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
8 changes: 4 additions & 4 deletions elpy/tests/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,19 +818,19 @@ def test_should_return_none_for_bad_identifier(self):
self.assertIsNone(docstring)


class RPCGetRenameDiffTests(GenericRPCTests):
class RPCGetRenameDiffTests(object):
METHOD = "rpc_get_rename_diff"


class RPCGetExtractFunctionDiffTests(GenericRPCTests):
class RPCGetExtractFunctionDiffTests(object):
METHOD = "rpc_get_extract_function_diff"


class RPCGetExtractVariableDiffTests(GenericRPCTests):
class RPCGetExtractVariableDiffTests(object):
METHOD = "rpc_get_extract_variable_diff"


class RPCGetInlineDiffTests(GenericRPCTests):
class RPCGetInlineDiffTests(object):
METHOD = "rpc_get_inline_diff"


Expand Down
9 changes: 5 additions & 4 deletions elpy/tests/test_jedibackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ class TestRunWithDebug(unittest.TestCase):
def test_should_call_method(self, Script):
Script.return_value.test_method.return_value = "test-result"

result = jedibackend.run_with_debug(jedi, 'test_method', 1, 2, arg=3)
result = jedibackend.run_with_debug(jedi, 'test_method', {}, 1, 2,
arg=3)

Script.assert_called_with(1, 2, arg=3)
self.assertEqual(result, 'test-result')
Expand All @@ -287,7 +288,7 @@ def test_should_keep_debug_info(self, set_debug_function, Script):
Script.side_effect = RuntimeError

try:
jedibackend.run_with_debug(jedi, 'test_method', 1, 2, arg=3)
jedibackend.run_with_debug(jedi, 'test_method', {}, 1, 2, arg=3)
except rpc.Fault as e:
self.assertGreaterEqual(e.code, 400)
self.assertIsNotNone(e.data)
Expand All @@ -308,7 +309,7 @@ def test_should_keep_error_text(self, set_debug_function, Script):
Script.side_effect = RuntimeError

try:
jedibackend.run_with_debug(jedi, 'test_method', 1, 2, arg=3)
jedibackend.run_with_debug(jedi, 'test_method', {}, 1, 2, arg=3)
except rpc.Fault as e:
self.assertEqual(str(e), str(RuntimeError()))
self.assertEqual(e.message, str(RuntimeError()))
Expand Down Expand Up @@ -369,4 +370,4 @@ def set_debug(function, speed=True):
Script.return_value.test_method.side_effect = Exception

with self.assertRaises(rpc.Fault):
jedibackend.run_with_debug(jedi, 'test_method', 1, 2, arg=3)
jedibackend.run_with_debug(jedi, 'test_method', {}, 1, 2, arg=3)
12 changes: 9 additions & 3 deletions elpy/tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def assert_calls_backend(self, method, add_kwargs={}):
get_source.assert_called_with("source")
getattr(backend, method).assert_called_with(
"filename", "transformed source", "offset",
**add_kwargs
*[add_kwargs[key] for key in add_kwargs.keys()]
)


Expand Down Expand Up @@ -217,7 +217,8 @@ def test_should_handle_no_backend(self):

class TestRPCGetRenameDiff(BackendCallTestCase):
def test_should_call_backend(self):
self.assert_calls_backend("rpc_get_rename_diff")
self.assert_calls_backend("rpc_get_rename_diff",
add_kwargs={'new_name': 'new_name'})

def test_should_handle_no_backend(self):
self.srv.backend = None
Expand All @@ -227,7 +228,12 @@ def test_should_handle_no_backend(self):

class TestRPCGetExtract_VariableDiff(BackendCallTestCase):
def test_should_call_backend(self):
self.assert_calls_backend("rpc_get_extract_variable_diff")
self.assert_calls_backend("rpc_get_extract_variable_diff",
add_kwargs={'new_name': 'name',
'line_beg': 12,
'line_end': 13,
'col_beg': 3,
'col_end': 5})

def test_should_handle_no_backend(self):
self.srv.backend = None
Expand Down

0 comments on commit 990fb58

Please sign in to comment.