From e1e2ed8fcc9e0e59129f78cef64decbe04b05c1c Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Sun, 24 Feb 2013 22:45:10 +0100 Subject: [PATCH 1/2] Add a test for docstring in call signature --- jedi/evaluate_representation.py | 2 +- test/regression.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/jedi/evaluate_representation.py b/jedi/evaluate_representation.py index e294e1d1..74ce5b46 100644 --- a/jedi/evaluate_representation.py +++ b/jedi/evaluate_representation.py @@ -169,7 +169,7 @@ class Instance(use_metaclass(cache.CachedMetaClass, Executable)): def __getattr__(self, name): if name not in ['start_pos', 'end_pos', 'name', 'get_imports', - 'docstr', 'asserts']: + 'doc', 'docstr', 'asserts']: raise AttributeError("Instance %s: Don't touch this (%s)!" % (self, name)) return getattr(self.base, name) diff --git a/test/regression.py b/test/regression.py index a7cdc12f..67b1e7d3 100755 --- a/test/regression.py +++ b/test/regression.py @@ -90,6 +90,15 @@ class TestRegression(TestBase): if not is_py25: assert len(r[0].doc) > 100 + def test_function_call_signature(self): + defs = self.definition(""" + def f(x, y=1, z='a'): + pass + f""") + doc = defs[0].doc + doc = defs[0].doc # removing this line won't work + assert "f(x, y = 1, z = 'a')" in doc + def test_definition_at_zero(self): assert self.definition("a", (1, 1)) == [] s = self.definition("str", (1, 1)) From 4ba9fd2b683d26bd3ebc11c774fc538335a4b369 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Mon, 25 Feb 2013 01:43:22 +0100 Subject: [PATCH 2/2] Fix Statement.get_code Parsed Statement.assignment_details must be used. Otherwise, incorrect code is returned at the first time Statement.get_code is called. --- jedi/parsing_representation.py | 2 +- test/regression.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/jedi/parsing_representation.py b/jedi/parsing_representation.py index 44a78344..c3fa3aa3 100644 --- a/jedi/parsing_representation.py +++ b/jedi/parsing_representation.py @@ -715,7 +715,7 @@ class Statement(Simple): return ''.join(pieces) return '%s %s ' % (''.join(pieces), assignment) - code = ''.join(assemble(*a) for a in self._assignment_details) + code = ''.join(assemble(*a) for a in self.assignment_details) code += assemble(self.get_commands()) if new_line: diff --git a/test/regression.py b/test/regression.py index 67b1e7d3..314dde67 100755 --- a/test/regression.py +++ b/test/regression.py @@ -96,7 +96,6 @@ class TestRegression(TestBase): pass f""") doc = defs[0].doc - doc = defs[0].doc # removing this line won't work assert "f(x, y = 1, z = 'a')" in doc def test_definition_at_zero(self):