Skip to content

Commit

Permalink
test if os is available before testing actions
Browse files Browse the repository at this point in the history
  • Loading branch information
youben11 committed Oct 29, 2019
1 parent 8242066 commit 49ee9dc
Showing 1 changed file with 32 additions and 26 deletions.
58 changes: 32 additions & 26 deletions test/plugins/test_importmagic_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,32 +37,38 @@ def test_importmagic_lint():
os.remove(name)


# def test_importmagic_actions(config):
# context = {
# 'diagnostics': [
# {
# 'range':
# {
# 'start': {'line': 1, 'character': 8},
# 'end': {'line': 1, 'character': 15}
# },
# 'message': "Unresolved import 'listdir'",
# 'severity': 4,
# 'source': 'importmagic'
# }
# ]
# }
def test_importmagic_actions(config):
# Environment must have os
try:
import os as test_import
except:
return

context = {
'diagnostics': [
{
'range':
{
'start': {'line': 1, 'character': 8},
'end': {'line': 1, 'character': 15}
},
'message': "Unresolved import 'listdir'",
'severity': 4,
'source': 'importmagic'
}
]
}

# try:
# name, doc = temp_document(DOC)
# actions = importmagic_lint.pyls_code_actions(config, doc, context)
# action = [a for a in actions if a['title'] == 'Import "listdir" from "os"'][0]
# arguments = action['arguments']
try:
name, doc = temp_document(DOC)
actions = importmagic_lint.pyls_code_actions(config, doc, context)
action = [a for a in actions if a['title'] == 'Import "listdir" from "os"'][0]
arguments = action['arguments']

# assert action['command'] == 'importmagic.addimport'
# assert arguments['startLine'] == 1
# assert arguments['endLine'] == 1
# assert arguments['newText'] == 'from os import listdir\n\n\n'
assert action['command'] == 'importmagic.addimport'
assert arguments['startLine'] == 1
assert arguments['endLine'] == 1
assert arguments['newText'] == 'from os import listdir\n\n\n'

# finally:
# os.remove(name)
finally:
os.remove(name)

0 comments on commit 49ee9dc

Please sign in to comment.