@ -8,19 +8,19 @@ import flaskext_migrate as migrate
def test_simple_from_import ( ) :
def test_simple_from_import ( ) :
red = RedBaron ( " from flask.ext import foo " )
red = RedBaron ( " from flask.ext import foo " )
output = migrate . fix ( red )
output = migrate . fix_tester ( red )
assert output == " import flask_foo as foo "
assert output == " import flask_foo as foo "
def test_from_to_from_import ( ) :
def test_from_to_from_import ( ) :
red = RedBaron ( " from flask.ext.foo import bar " )
red = RedBaron ( " from flask.ext.foo import bar " )
output = migrate . fix ( red )
output = migrate . fix_tester ( red )
assert output == " from flask_foo import bar as bar "
assert output == " from flask_foo import bar as bar "
def test_multiple_import ( ) :
def test_multiple_import ( ) :
red = RedBaron ( " from flask.ext.foo import bar, foobar, something " )
red = RedBaron ( " from flask.ext.foo import bar, foobar, something " )
output = migrate . fix ( red )
output = migrate . fix_tester ( red )
assert output == " from flask_foo import bar, foobar, something "
assert output == " from flask_foo import bar, foobar, something "
@ -29,23 +29,35 @@ def test_multiline_import():
bar , \
bar , \
foobar , \
foobar , \
something " )
something " )
output = migrate . fix ( red )
output = migrate . fix_tester ( red )
assert output == " from flask_foo import bar, foobar, something "
assert output == " from flask_foo import bar, foobar, something "
def test_module_import ( ) :
def test_module_import ( ) :
red = RedBaron ( " import flask.ext.foo " )
red = RedBaron ( " import flask.ext.foo " )
output = migrate . fix ( red )
output = migrate . fix_tester ( red )
assert output == " import flask_foo "
assert output == " import flask_foo as foo "
def test_module_import ( ) :
def test_named_module_import ( ) :
red = RedBaron ( " import flask.ext.foo as foobar " )
output = migrate . fix_tester ( red )
assert output == " import flask_foo as foobar "
def test__named_from_import ( ) :
red = RedBaron ( " from flask.ext.foo import bar as baz " )
red = RedBaron ( " from flask.ext.foo import bar as baz " )
output = migrate . fix ( red )
output = migrate . fix_tester ( red )
assert output == " from flask_foo import bar as baz "
assert output == " from flask_foo import bar as baz "
def test_parens_import ( ) :
def test_parens_import ( ) :
red = RedBaron ( " from flask.ext.foo import (bar, foo, foobar) " )
red = RedBaron ( " from flask.ext.foo import (bar, foo, foobar) " )
output = migrate . fix ( red )
output = migrate . fix_tester ( red )
assert output == " from flask_foo import (bar, foo, foobar) "
assert output == " from flask_foo import (bar, foo, foobar) "
def test_function_call_migration ( ) :
red = RedBaron ( " flask.ext.foo(var) " )
output = migrate . fix_tester ( red )
assert output == " flask_foo(var) "