From 96f7b07caf15a23a67e9e9dfd086d38e400b2db5 Mon Sep 17 00:00:00 2001 From: Redian Ibra Date: Thu, 26 Nov 2015 21:43:05 +0000 Subject: [PATCH] Skip test if redbaron is not installed --- scripts/test_import_migration.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/scripts/test_import_migration.py b/scripts/test_import_migration.py index 11d1f6a3..f000f2b1 100644 --- a/scripts/test_import_migration.py +++ b/scripts/test_import_migration.py @@ -2,30 +2,29 @@ # # Author: Keyan Pishdadian import pytest -from redbaron import RedBaron +redbaron = pytest.importorskip("redbaron") import flaskext_migrate as migrate - def test_simple_from_import(): - red = RedBaron("from flask.ext import foo") + red = redbaron.RedBaron("from flask.ext import foo") output = migrate.fix_tester(red) assert output == "import flask_foo as foo" def test_from_to_from_import(): - red = RedBaron("from flask.ext.foo import bar") + red = redbaron.RedBaron("from flask.ext.foo import bar") output = migrate.fix_tester(red) assert output == "from flask_foo import bar as bar" def test_multiple_import(): - red = RedBaron("from flask.ext.foo import bar, foobar, something") + red = redbaron.RedBaron("from flask.ext.foo import bar, foobar, something") output = migrate.fix_tester(red) assert output == "from flask_foo import bar, foobar, something" def test_multiline_import(): - red = RedBaron("from flask.ext.foo import \ + red = redbaron.RedBaron("from flask.ext.foo import \ bar,\ foobar,\ something") @@ -34,37 +33,37 @@ def test_multiline_import(): def test_module_import(): - red = RedBaron("import flask.ext.foo") + red = redbaron.RedBaron("import flask.ext.foo") output = migrate.fix_tester(red) assert output == "import flask_foo" def test_named_module_import(): - red = RedBaron("import flask.ext.foo as foobar") + red = redbaron.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.RedBaron("from flask.ext.foo import bar as baz") output = migrate.fix_tester(red) assert output == "from flask_foo import bar as baz" def test_parens_import(): - red = RedBaron("from flask.ext.foo import (bar, foo, foobar)") + red = redbaron.RedBaron("from flask.ext.foo import (bar, foo, foobar)") output = migrate.fix_tester(red) assert output == "from flask_foo import (bar, foo, foobar)" def test_function_call_migration(): - red = RedBaron("flask.ext.foo(var)") + red = redbaron.RedBaron("flask.ext.foo(var)") output = migrate.fix_tester(red) assert output == "flask_foo(var)" def test_nested_function_call_migration(): - red = RedBaron("import flask.ext.foo\n\n" + red = redbaron.RedBaron("import flask.ext.foo\n\n" "flask.ext.foo.bar(var)") output = migrate.fix_tester(red) assert output == ("import flask_foo\n\n" @@ -72,6 +71,6 @@ def test_nested_function_call_migration(): def test_no_change_to_import(): - red = RedBaron("from flask import Flask") + red = redbaron.RedBaron("from flask import Flask") output = migrate.fix_tester(red) assert output == "from flask import Flask"