[Piglit] [PATCH v3 20/28] framework/profile: Split try/except block
Dylan Baker
dylan at pnwbakers.com
Mon Oct 31 17:50:16 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 63d7f86..1cd0c0d 100644
--- a/framework/profile.py
+++ b/framework/profile.py
@@ -390,15 +390,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