[Piglit] [PATCH v4 21/27] framework/profile: Split try/except block
Dylan Baker
dylan at pnwbakers.com
Wed Nov 9 20:53:33 UTC 2016
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 at intel.com>
---
framework/profile.py | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/framework/profile.py b/framework/profile.py
index 042cf98..8449e7a 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):
--
git-series 0.8.10
More information about the Piglit
mailing list