From 450eaee4d9d16a77331354c9adc7a4456fe01dd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sat, 15 Dec 2012 19:35:17 +0100 Subject: [PATCH 1/3] Hide functools and imp packages in global skimage namespace --- skimage/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/skimage/__init__.py b/skimage/__init__.py index 3277919e..5a84dd68 100644 --- a/skimage/__init__.py +++ b/skimage/__init__.py @@ -52,8 +52,8 @@ img_as_ubyte """ import os.path as _osp -import imp -import functools +import imp as _imp +import functools as _functools pkg_dir = _osp.abspath(_osp.dirname(__file__)) data_dir = _osp.join(pkg_dir, 'data') @@ -65,7 +65,7 @@ except ImportError: try: - imp.find_module('nose') + _imp.find_module('nose') except ImportError: def test(verbose=False): """This would invoke the skimage test suite, but nose couldn't be @@ -81,7 +81,7 @@ else: args.extend(['-v', '-s']) nose.run('skimage', argv=args) -test_verbose = functools.partial(test, verbose=True) +test_verbose = _functools.partial(test, verbose=True) test_verbose.__doc__ = test.__doc__ From e0f4cd097817342ed0ed5cf4b40bd429f8782221 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sat, 15 Dec 2012 19:35:49 +0100 Subject: [PATCH 2/3] Fix double space in warning message --- skimage/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skimage/__init__.py b/skimage/__init__.py index 5a84dd68..1435892c 100644 --- a/skimage/__init__.py +++ b/skimage/__init__.py @@ -71,7 +71,7 @@ except ImportError: """This would invoke the skimage test suite, but nose couldn't be imported so the test suite can not run. """ - raise ImportError("Could not load nose. Unit tests not available.") + raise ImportError("Could not load nose. Unit tests not available.") else: def test(verbose=False): """Invoke the skimage test suite.""" From 746d815dfa48e2cd5e99525ed00e906ad0fe3119 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sat, 15 Dec 2012 20:08:18 +0100 Subject: [PATCH 3/3] Fix recursion problem with nose test suite --- skimage/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/skimage/__init__.py b/skimage/__init__.py index 1435892c..daac238c 100644 --- a/skimage/__init__.py +++ b/skimage/__init__.py @@ -67,13 +67,13 @@ except ImportError: try: _imp.find_module('nose') except ImportError: - def test(verbose=False): + def _test(verbose=False): """This would invoke the skimage test suite, but nose couldn't be imported so the test suite can not run. """ raise ImportError("Could not load nose. Unit tests not available.") else: - def test(verbose=False): + def _test(verbose=False): """Invoke the skimage test suite.""" import nose args = ['', pkg_dir, '--exe'] @@ -81,6 +81,9 @@ else: args.extend(['-v', '-s']) nose.run('skimage', argv=args) +# do not use `test` as function name as this leads to a recursion problem with +# the nose test suite +test = _test test_verbose = _functools.partial(test, verbose=True) test_verbose.__doc__ = test.__doc__