mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-10 07:41:51 +08:00
renaming tests refactored. It's now much easier and understandable to create rename tests
This commit is contained in:
@@ -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
|
I always leave a little bit of space to add room for additions, because the
|
||||||
results always contain position informations.
|
results always contain position informations.
|
||||||
"""
|
"""
|
||||||
#< 4 (7,4), (10,0), (12,0)
|
#< 4 (0,4), (3,0), (5,0)
|
||||||
def abc(): pass
|
def abc(): pass
|
||||||
|
|
||||||
#< 0 (7,4), (10,0), (12,0)
|
#< 0 (-3,4), (0,0), (2,0)
|
||||||
abc.d.a.bsaasd.abc.d
|
abc.d.a.bsaasd.abc.d
|
||||||
|
|
||||||
abc
|
abc
|
||||||
@@ -19,29 +19,29 @@ abc
|
|||||||
|
|
||||||
abc =
|
abc =
|
||||||
|
|
||||||
#< (20,0), (23,0)
|
#< (-3,0), (0,0)
|
||||||
abc
|
abc
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Abc = 3
|
Abc = 3
|
||||||
|
|
||||||
#< 6 (30,6), (32,4), (35,8), (47,0)
|
#< 6 (0,6), (2,4), (5,8), (17,0)
|
||||||
class Abc():
|
class Abc():
|
||||||
#< (30,6), (32,4), (35,8), (47,0)
|
#< (-2,6), (0,4), (3,8), (15,0)
|
||||||
Abc
|
Abc
|
||||||
|
|
||||||
def Abc(self):
|
def Abc(self):
|
||||||
Abc; self.c = 3
|
Abc; self.c = 3
|
||||||
|
|
||||||
#< 17 (38,16), (40,8)
|
#< 17 (0,16), (2,8)
|
||||||
def a(self, Abc):
|
def a(self, Abc):
|
||||||
#< 10 (38,16), (40,8)
|
#< 10 (-2,16), (0,8)
|
||||||
Abc
|
Abc
|
||||||
|
|
||||||
#< 19 (43,18), (45,8)
|
#< 19 (0,18), (2,8)
|
||||||
def self_test(self):
|
def self_test(self):
|
||||||
#< 12 (43,18), (45,8)
|
#< 12 (-2,18), (0,8)
|
||||||
self.b
|
self.b
|
||||||
|
|
||||||
Abc.d.Abc
|
Abc.d.Abc
|
||||||
@@ -51,49 +51,49 @@ Abc.d.Abc
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#< 4 (55,4), (59,1)
|
#< 4 (0,4), (4,1)
|
||||||
def blub():
|
def blub():
|
||||||
|
|
||||||
|
|
||||||
#< (55,4), (59,1)
|
#< (-4,4), (0,1)
|
||||||
@blub
|
@blub
|
||||||
def a(): pass
|
def a(): pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#< (65,7), (68,0)
|
#< (0,7), (3,0)
|
||||||
import module_not_exists
|
import module_not_exists
|
||||||
|
|
||||||
#< (65,7), (68,0)
|
#< (-3,7), (0,0)
|
||||||
module_not_exists
|
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
|
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
|
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
|
from import_tree.rename1 import abc
|
||||||
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
|
from import_tree.rename1 import abc
|
||||||
|
|
||||||
#< (88, 32),
|
#< (0, 32),
|
||||||
from import_tree.rename1 import not_existing
|
from import_tree.rename1 import not_existing
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
response = 5
|
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 = HttpResponse(mimetype='application/pdf')
|
||||||
response['Content-Disposition'] = 'attachment; filename=%s.pdf' % id
|
response['Content-Disposition'] = 'attachment; filename=%s.pdf' % id
|
||||||
response.write(pdf)
|
response.write(pdf)
|
||||||
#< (95, 0), (96, 0), (97, 0), (99, 0)
|
#< (-4,0), (-3,0), (-2,0), (0,0)
|
||||||
response
|
response
|
||||||
|
|||||||
17
test/run.py
17
test/run.py
@@ -85,11 +85,20 @@ def run_related_name_test(script, correct, line_nr):
|
|||||||
"""
|
"""
|
||||||
result = script.related_names()
|
result = script.related_names()
|
||||||
correct = correct.strip()
|
correct = correct.strip()
|
||||||
comp_str = sorted(r.start_pos for r in result)
|
compare = sorted((r.module_name, r.start_pos[0], r.start_pos[1])
|
||||||
correct = sorted(literal_eval(correct))
|
for r in result)
|
||||||
if sorted(comp_str) != sorted(correct):
|
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'\
|
print('Solution @%s not right, received %s, wanted %s'\
|
||||||
% (line_nr - 1, comp_str, correct))
|
% (line_nr - 1, compare, wanted))
|
||||||
return 1
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user