Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raise EasyBuildError rather than ImportError in only_if_module_is_available decorator #1662

Merged
merged 1 commit into from
Mar 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion easybuild/tools/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def error(*args, **kwargs):
msg += " (provided by Python package %s, available from %s)" % (pkgname, url)
elif url:
msg += " (available from %s)" % url
raise ImportError(msg)
raise EasyBuildError("ImportError: %s", msg)
return error

return wrap
5 changes: 3 additions & 2 deletions test/framework/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import vsc

import easybuild.framework
from easybuild.tools.build_log import EasyBuildError
from easybuild.tools.filetools import read_file
from easybuild.tools.utilities import only_if_module_is_available

Expand Down Expand Up @@ -84,15 +85,15 @@ def bar():
pass

err_pat = "required module 'nosuchmoduleoutthere' is not available.*package nosuchpkg.*pypi/nosuchpkg"
self.assertErrorRegex(ImportError, err_pat, bar)
self.assertErrorRegex(EasyBuildError, err_pat, bar)

class Foo():
@only_if_module_is_available('thisdoesnotexist', url='http://example.com')
def foobar(self):
pass

err_pat = r"required module 'thisdoesnotexist' is not available \(available from http://example.com\)"
self.assertErrorRegex(ImportError, err_pat, Foo().foobar)
self.assertErrorRegex(EasyBuildError, err_pat, Foo().foobar)


def suite():
Expand Down