From f80bfcaa28da98972002fb906c2559babe75801e Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Sun, 18 Sep 2011 03:26:46 +0200 Subject: [PATCH] Added tests for old imports --- flask/testsuite/ext.py | 33 ++++++++++++++++--- .../testsuite/test_apps/flaskext/__init__.py | 0 .../flaskext/oldext_package/__init__.py | 1 + .../flaskext/oldext_package/submodule.py | 2 ++ .../test_apps/flaskext/oldext_simple.py | 1 + 5 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 flask/testsuite/test_apps/flaskext/__init__.py create mode 100644 flask/testsuite/test_apps/flaskext/oldext_package/__init__.py create mode 100644 flask/testsuite/test_apps/flaskext/oldext_package/submodule.py create mode 100644 flask/testsuite/test_apps/flaskext/oldext_simple.py diff --git a/flask/testsuite/ext.py b/flask/testsuite/ext.py index ad8d0d16..41bbabeb 100644 --- a/flask/testsuite/ext.py +++ b/flask/testsuite/ext.py @@ -31,29 +31,52 @@ class ExtImportHookTestCase(FlaskTestCase): import_hooks += 1 self.assert_equal(import_hooks, 1) - def test_flaskext_simple_import_normal(self): + def test_flaskext_new_simple_import_normal(self): from flask.ext.newext_simple import ext_id self.assert_equal(ext_id, 'newext_simple') - def test_flaskext_simple_import_module(self): + def test_flaskext_new_simple_import_module(self): from flask.ext import newext_simple self.assert_equal(newext_simple.ext_id, 'newext_simple') self.assert_equal(newext_simple.__name__, 'flask_newext_simple') - def test_flaskext_package_import_normal(self): + def test_flaskext_new_package_import_normal(self): from flask.ext.newext_package import ext_id self.assert_equal(ext_id, 'newext_package') - def test_flaskext_package_import_module(self): + def test_flaskext_new_package_import_module(self): from flask.ext import newext_package self.assert_equal(newext_package.ext_id, 'newext_package') self.assert_equal(newext_package.__name__, 'flask_newext_package') - def test_flaskext_package_import_submodule(self): + def test_flaskext_new_package_import_submodule(self): from flask.ext.newext_package import submodule self.assert_equal(submodule.__name__, 'flask_newext_package.submodule') self.assert_equal(submodule.test_function(), 42) + def test_flaskext_old_simple_import_normal(self): + from flask.ext.oldext_simple import ext_id + self.assert_equal(ext_id, 'oldext_simple') + + def test_flaskext_old_simple_import_module(self): + from flask.ext import oldext_simple + self.assert_equal(oldext_simple.ext_id, 'oldext_simple') + self.assert_equal(oldext_simple.__name__, 'flaskext.oldext_simple') + + def test_flaskext_old_package_import_normal(self): + from flask.ext.oldext_package import ext_id + self.assert_equal(ext_id, 'oldext_package') + + def test_flaskext_old_package_import_module(self): + from flask.ext import oldext_package + self.assert_equal(oldext_package.ext_id, 'oldext_package') + self.assert_equal(oldext_package.__name__, 'flaskext.oldext_package') + + def test_flaskext_old_package_import_submodule(self): + from flask.ext.oldext_package import submodule + self.assert_equal(submodule.__name__, 'flaskext.oldext_package.submodule') + self.assert_equal(submodule.test_function(), 42) + def suite(): suite = unittest.TestSuite() diff --git a/flask/testsuite/test_apps/flaskext/__init__.py b/flask/testsuite/test_apps/flaskext/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/flask/testsuite/test_apps/flaskext/oldext_package/__init__.py b/flask/testsuite/test_apps/flaskext/oldext_package/__init__.py new file mode 100644 index 00000000..7c462065 --- /dev/null +++ b/flask/testsuite/test_apps/flaskext/oldext_package/__init__.py @@ -0,0 +1 @@ +ext_id = 'oldext_package' diff --git a/flask/testsuite/test_apps/flaskext/oldext_package/submodule.py b/flask/testsuite/test_apps/flaskext/oldext_package/submodule.py new file mode 100644 index 00000000..26ad56b7 --- /dev/null +++ b/flask/testsuite/test_apps/flaskext/oldext_package/submodule.py @@ -0,0 +1,2 @@ +def test_function(): + return 42 diff --git a/flask/testsuite/test_apps/flaskext/oldext_simple.py b/flask/testsuite/test_apps/flaskext/oldext_simple.py new file mode 100644 index 00000000..c6664a78 --- /dev/null +++ b/flask/testsuite/test_apps/flaskext/oldext_simple.py @@ -0,0 +1 @@ +ext_id = 'oldext_simple'