diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2016-10-14 17:30:58 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2016-11-10 10:51:02 -0800 |
commit | 0d4eb8c6b7bb589bd36b8578979b836155e3bc45 (patch) | |
tree | 9f956ff287d4234d71125a4fa560892f82c2d27e /framework | |
parent | fc71aba3e345ff39e9f995ad034ad6eae2d57404 (diff) |
framework/profile: Split try/except block
This will avoid catching AttributeErrors when importing, and only catch
them if mod.profile doesn't exist.
Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
Diffstat (limited to 'framework')
-rw-r--r-- | framework/profile.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/framework/profile.py b/framework/profile.py index 042cf9865..8449e7afc 100644 --- a/framework/profile.py +++ b/framework/profile.py @@ -388,15 +388,18 @@ def load_test_profile(filename): try: mod = importlib.import_module('tests.{0}'.format( os.path.splitext(os.path.basename(filename))[0])) + except ImportError: + raise exceptions.PiglitFatalError( + 'Failed to import "{}", there is either something wrong with the ' + 'module or it doesn\'t exist. Check your spelling?'.format( + filename)) + + try: return mod.profile except AttributeError: raise exceptions.PiglitFatalError( - 'There is not profile attribute in module {}.\n' + 'There is no "profile" attribute in module {}.\n' 'Did you specify the right file?'.format(filename)) - except ImportError: - raise exceptions.PiglitFatalError( - 'There is no test profile called "{}".\n' - 'Check your spelling?'.format(filename)) def run(profiles, logger, backend, concurrency): |