@@ -37,32 +37,38 @@ def test_importmagic_lint():
3737 os .remove (name )
3838
3939
40- # def test_importmagic_actions(config):
41- # context = {
42- # 'diagnostics': [
43- # {
44- # 'range':
45- # {
46- # 'start': {'line': 1, 'character': 8},
47- # 'end': {'line': 1, 'character': 15}
48- # },
49- # 'message': "Unresolved import 'listdir'",
50- # 'severity': 4,
51- # 'source': 'importmagic'
52- # }
53- # ]
54- # }
40+ def test_importmagic_actions (config ):
41+ # Environment must have os
42+ try :
43+ import os as test_import
44+ except :
45+ return
46+
47+ context = {
48+ 'diagnostics' : [
49+ {
50+ 'range' :
51+ {
52+ 'start' : {'line' : 1 , 'character' : 8 },
53+ 'end' : {'line' : 1 , 'character' : 15 }
54+ },
55+ 'message' : "Unresolved import 'listdir'" ,
56+ 'severity' : 4 ,
57+ 'source' : 'importmagic'
58+ }
59+ ]
60+ }
5561
56- # try:
57- # name, doc = temp_document(DOC)
58- # actions = importmagic_lint.pyls_code_actions(config, doc, context)
59- # action = [a for a in actions if a['title'] == 'Import "listdir" from "os"'][0]
60- # arguments = action['arguments']
62+ try :
63+ name , doc = temp_document (DOC )
64+ actions = importmagic_lint .pyls_code_actions (config , doc , context )
65+ action = [a for a in actions if a ['title' ] == 'Import "listdir" from "os"' ][0 ]
66+ arguments = action ['arguments' ]
6167
62- # assert action['command'] == 'importmagic.addimport'
63- # assert arguments['startLine'] == 1
64- # assert arguments['endLine'] == 1
65- # assert arguments['newText'] == 'from os import listdir\n\n\n'
68+ assert action ['command' ] == 'importmagic.addimport'
69+ assert arguments ['startLine' ] == 1
70+ assert arguments ['endLine' ] == 1
71+ assert arguments ['newText' ] == 'from os import listdir\n \n \n '
6672
67- # finally:
68- # os.remove(name)
73+ finally :
74+ os .remove (name )
0 commit comments