Skip to content
Browse files

assistant: handle "as" keyword in import statement

  • Loading branch information...
1 parent 8621109 commit 5e81154ca4160995dd3ae215e6c8698f661c13d6 @baverman committed Dec 20, 2011
Showing with 14 additions and 2 deletions.
  1. +2 −2 supplement/assistant.py
  2. +12 −0 tests/test_assist.py
View
4 supplement/assistant.py
@@ -111,13 +111,13 @@ def parse_import(tokens):
return '', ''
while True:
- tid, value = tokens.get(',', '.', 0)
+ tid, value = tokens.get(',', '.', 'as', 0)
if not tid:
break
elif value == '.':
pks.append(match)
match = ''
- elif value == ',':
+ elif value == ',' or value == 'as':
pks[:] = []
match = ''
else:
View
12 tests/test_assist.py
@@ -138,6 +138,18 @@ def test_assist_for_import_from_relative_modules(project):
assert 'test' in result
+def test_assist_for_import_from_relative_modules_with_aliases(project):
+ project.create_module('package.toimport', '''
+ test = 1
+ boo = 2
+ ''')
+
+ result = do_assist(project, '''
+ from .toimport import boo as foo, t|
+ ''', filename='package/test.py')
+
+ assert 'test' in result
+
def test_assist_for_import_from_relative_modules_on_real_fs(project):
import os.path
root = os.path.dirname(os.path.dirname(__file__))

0 comments on commit 5e81154

Please sign in to comment.
Something went wrong with that request. Please try again.