Skip to content

Commit

Permalink
Merge pull request #1662 from boegel/raise_eberror_not_importerror
Browse files Browse the repository at this point in the history
raise EasyBuildError rather than ImportError in only_if_module_is_available decorator
  • Loading branch information
boegel committed Mar 10, 2016
2 parents 5c7ac16 + 1a0c1f2 commit 3694b0d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
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

0 comments on commit 3694b0d

Please sign in to comment.