From 6322df11f34b639cf240af133eb8104cedd1c226 Mon Sep 17 00:00:00 2001 From: David Halter Date: Mon, 24 Dec 2012 17:12:46 +0100 Subject: [PATCH] renaming tests refactored. It's now much easier and understandable to create rename tests --- test/completion/renaming.py | 40 ++++++++++++++++++------------------- test/run.py | 17 ++++++++++++---- 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/test/completion/renaming.py b/test/completion/renaming.py index 94e18e80..a80a909b 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 (0,4), (3,0), (5,0) def abc(): pass -#< 0 (7,4), (10,0), (12,0) +#< 0 (-3,4), (0,0), (2,0) abc.d.a.bsaasd.abc.d abc @@ -19,29 +19,29 @@ abc abc = -#< (20,0), (23,0) +#< (-3,0), (0,0) abc Abc = 3 -#< 6 (30,6), (32,4), (35,8), (47,0) +#< 6 (0,6), (2,4), (5,8), (17,0) class Abc(): - #< (30,6), (32,4), (35,8), (47,0) + #< (-2,6), (0,4), (3,8), (15,0) Abc def Abc(self): Abc; self.c = 3 - #< 17 (38,16), (40,8) + #< 17 (0,16), (2,8) def a(self, Abc): - #< 10 (38,16), (40,8) + #< 10 (-2,16), (0,8) Abc - #< 19 (43,18), (45,8) + #< 19 (0,18), (2,8) def self_test(self): - #< 12 (43,18), (45,8) + #< 12 (-2,18), (0,8) self.b Abc.d.Abc @@ -51,49 +51,49 @@ Abc.d.Abc -#< 4 (55,4), (59,1) +#< 4 (0,4), (4,1) def blub(): -#< (55,4), (59,1) +#< (-4,4), (0,1) @blub def a(): pass -#< (65,7), (68,0) +#< (0,7), (3,0) import module_not_exists -#< (65,7), (68,0) +#< (-3,7), (0,0) module_not_exists -#< (1,0), (75,24), (78,0), (81,17), (4,5), (85,17), (88,17) +#< ('rename1', 1,0), (0,24), (3,0), (6,17), ('rename2', 4,5), (10,17), (13,17) from import_tree import rename1 -#< (78,8), (3,0), (4,20), (6,0), (81,32), (85,32), (82,0) +#< (0,8), ('rename1',3,0), ('rename2',4,20), ('rename2',6,0), (3,32), (7,32), (4,0) rename1.abc -#< (78,8), (3,0), (4,20), (6,0), (81,32), (85,32), (82,0) +#< (-3,8), ('rename1', 3,0), ('rename2', 4,20), ('rename2', 6,0), (0,32), (4,32), (1,0) from import_tree.rename1 import abc abc -#< 20 (1,0), (4,5), (75,24), (78,0), (81,17), (85,17), (88,17) +#< 20 ('rename1', 1,0), ('rename2', 4,5), (-10,24), (-7,0), (-4,17), (0,17), (3,17) from import_tree.rename1 import abc -#< (88, 32), +#< (0, 32), from import_tree.rename1 import not_existing response = 5 -#< 0 (95, 0), (96, 0), (97, 0), (99, 0) +#< 0 (0,0), (1,0), (2,0), (4,0) response = HttpResponse(mimetype='application/pdf') response['Content-Disposition'] = 'attachment; filename=%s.pdf' % id response.write(pdf) -#< (95, 0), (96, 0), (97, 0), (99, 0) +#< (-4,0), (-3,0), (-2,0), (0,0) response diff --git a/test/run.py b/test/run.py index dcfca2de..8bc3726c 100755 --- a/test/run.py +++ b/test/run.py @@ -85,11 +85,20 @@ def run_related_name_test(script, correct, line_nr): """ result = script.related_names() correct = correct.strip() - comp_str = sorted(r.start_pos for r in result) - correct = sorted(literal_eval(correct)) - if sorted(comp_str) != sorted(correct): + compare = sorted((r.module_name, r.start_pos[0], r.start_pos[1]) + for r in result) + wanted = [] + for pos_tup in literal_eval(correct): + if type(pos_tup[0]) == str: + # this means that there is a module specified + wanted.append(pos_tup) + else: + wanted.append(('renaming', line_nr + pos_tup[0], pos_tup[1])) + + wanted = sorted(wanted) + if compare != wanted: print('Solution @%s not right, received %s, wanted %s'\ - % (line_nr - 1, comp_str, correct)) + % (line_nr - 1, compare, wanted)) return 1 return 0