From c7e8278ca4568a234618240526e4d82cdd01c2b9 Mon Sep 17 00:00:00 2001 From: David Halter Date: Sat, 22 Sep 2012 16:06:30 +0200 Subject: [PATCH] changed rename tests --- jedi/api.py | 2 +- test/completion/renaming.py | 35 +++++++++++++++++++---------------- test/run.py | 6 +++--- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/jedi/api.py b/jedi/api.py index eaefac8a..593d6996 100644 --- a/jedi/api.py +++ b/jedi/api.py @@ -334,7 +334,7 @@ class Script(object): module.add(self.parser.module) names = dynamic.related_names(definitions, search_name, module) - for d in definitions: + for d in set(definitions): if isinstance(d, parsing.Module): names.append(dynamic.RelatedName(d, d)) else: diff --git a/test/completion/renaming.py b/test/completion/renaming.py index 7f960793..23c6405f 100644 --- a/test/completion/renaming.py +++ b/test/completion/renaming.py @@ -3,10 +3,10 @@ Renaming tests. This means search for related names. I always leave a little bit of space to add room for additions, because the results always contain position informations. """ -#< 4 (7,4) (10,0) (12,0) +#< 4 (7,4), (10,0), (12,0) def abc(): pass -#< 0 (7,4) (10,0) (12,0) +#< 0 (7,4), (10,0), (12,0) abc.d.a.bsaasd.abc.d abc @@ -19,29 +19,29 @@ abc abc = -#< (20,0) (23,0) +#< (20,0), (23,0) abc Abc = 3 -#< 6 (30,6) (32,4) (35,8) (47,0) +#< 6 (30,6), (32,4), (35,8), (47,0) class Abc(): - #< (30,6) (32,4) (35,8) (47,0) + #< (30,6), (32,4), (35,8), (47,0) Abc def Abc(self): Abc; self.c = 3 - #< 17 (38,16) (40,8) + #< 17 (38,16), (40,8) def a(self, Abc): - #< 10 (38,16) (40,8) + #< 10 (38,16), (40,8) Abc - #< 19 (43,18) (45,8) + #< 19 (43,18), (45,8) def self_test(self): - #< 12 (43,18) (45,8) + #< 12 (43,18), (45,8) self.b Abc.d.Abc @@ -51,32 +51,35 @@ Abc.d.Abc -#< 4 (55,4) (59,1) +#< 4 (55,4), (59,1) def blub(): -#< (55,4) (59,1) +#< (55,4), (59,1) @blub def a(): pass -#< (65,7) (68,0) +#< (65,7), (68,0) import module_not_exists -#< (65,7) (68,0) +#< (65,7), (68,0) module_not_exists - +#< (85,17), (75,24), (78,0), (81,17), (4,5) from import_tree import rename1 -#< (78,8) (3,0) (4,20) (6,0) (81,32) (82,0) (6,0) +#< (78,8), (3,0), (4,20), (6,0), (81,32), (82,0), (6,0) rename1.abc -#< (78,8) (3,0) (4,20) (6,0) (81,32) (82,0) (6,0) +#< (78,8), (3,0), (4,20), (6,0), (81,32), (82,0) from import_tree.rename1 import abc abc + +#< (75, 24), +from import_tree.rename1 import not_existing diff --git a/test/run.py b/test/run.py index d5defc77..73aab14d 100755 --- a/test/run.py +++ b/test/run.py @@ -84,9 +84,9 @@ def run_related_name_test(script, correct, line_nr): """ result = script.related_names() correct = correct.strip() - comp_str = set('(%s,%s)' % r.start_pos for r in result) - correct = set(correct.split(' ')) if correct else set() - if comp_str != correct: + comp_str = sorted(r.start_pos for r in result) + correct = sorted(literal_eval(correct)) + if sorted(comp_str) != sorted(correct): print('Solution @%s not right, received %s, wanted %s'\ % (line_nr - 1, comp_str, correct)) return 1