def test_imports_on_global_namespace_without_path():
 completions = Script('import operator').completions()
 assert ([c.name for c in completions] == ['operator'])
 completions = Script('import operator', path='example.py').completions()
 assert ([c.name for c in completions] == ['operator'])
 completions = Script('import keyword', path='example.py').completions()
 assert ([c.name for c in completions] == ['keyword'])
 completions = Script('import keyword').completions()
 assert ([c.name for c in completions] == ['keyword'])

def test_imports_on_global_namespace_without_path ( ) : completions = Script ( 'import operator' ) . completions ( ) assert ( [ c . name for c in completions ] == [ 'operator' ] ) completions = Script ( 'import operator' , path = 'example.py' ) . completions ( ) assert ( [ c . name for c in completions ] == [ 'operator' ] ) completions = Script ( 'import keyword' , path = 'example.py' ) . completions ( ) assert ( [ c . name for c in completions ] == [ 'keyword' ] ) completions = Script ( 'import keyword' ) . completions ( ) assert ( [ c . name for c in completions ] == [ 'keyword' ] )
if the path is none .