[PATCH 2/3] raise exception only when you want to report the result as CRASHED

Kamil Páral kparal at redhat.com
Tue Sep 14 11:04:36 UTC 2010


We will start using exceptions only when something goes wrong and we
want to report the test result as CRASHED. Otherwise we will just set
self.result and end the test normally.
---
 tests/rats_install/rats_install.py |    2 --
 tests/rats_sanity/rats_sanity.py   |    4 +---
 tests/repoclosure/repoclosure.py   |    3 ---
 tests/upgradepath/upgradepath.py   |   15 ++-------------
 4 files changed, 3 insertions(+), 21 deletions(-)

diff --git a/tests/rats_install/rats_install.py b/tests/rats_install/rats_install.py
index 21c95de..e4050d2 100644
--- a/tests/rats_install/rats_install.py
+++ b/tests/rats_install/rats_install.py
@@ -90,5 +90,3 @@ class rats_install(AutoQATest):
             except Exception, e:
                 print "Failed to send results to irb: %s" % str(e)
 
-        if self.result == 'FAILED':
-            raise error.TestFail
diff --git a/tests/rats_sanity/rats_sanity.py b/tests/rats_sanity/rats_sanity.py
index 8ae7081..3f1e915 100644
--- a/tests/rats_sanity/rats_sanity.py
+++ b/tests/rats_sanity/rats_sanity.py
@@ -49,7 +49,7 @@ class rats_sanity(AutoQATest):
         try:
             out = utils.system_output(cmd + " 2>&1", retain_output=True)
         except error.CmdError, e:
-            result = 'FAILED'
+            self.result = 'FAILED'
             out = e.result_obj.stdout
 
         if self.result is None:
@@ -73,5 +73,3 @@ class rats_sanity(AutoQATest):
             except Exception, e:
                 print "Failed to send results to irb: %s" % str(e)
 
-        if self.result == 'FAILED':
-            raise error.TestFail
diff --git a/tests/repoclosure/repoclosure.py b/tests/repoclosure/repoclosure.py
index f3ffb8a..c0e4838 100644
--- a/tests/repoclosure/repoclosure.py
+++ b/tests/repoclosure/repoclosure.py
@@ -19,7 +19,6 @@
 
 import autoqa.util
 from autotest_lib.client.bin import utils
-from autotest_lib.client.common_lib import error
 from autoqa.test import AutoQATest
 from autoqa.decorators import ExceptionCatcher
 
@@ -58,5 +57,3 @@ class repoclosure(AutoQATest):
         self.outputs = out
 
 
-        if unresolved_count:
-            raise error.TestFail, "%u packages with unresolved deps" % unresolved_count
diff --git a/tests/upgradepath/upgradepath.py b/tests/upgradepath/upgradepath.py
index 257eddc..dfbbb81 100755
--- a/tests/upgradepath/upgradepath.py
+++ b/tests/upgradepath/upgradepath.py
@@ -31,7 +31,6 @@ from autoqa.decorators import ExceptionCatcher
 from autotest_lib.client.bin import utils
 from autotest_lib.client.bin import test
 from autotest_lib.client.bin.test_config import config_loader
-from autotest_lib.client.common_lib import error
 
 
 class upgradepath(AutoQATest):
@@ -82,15 +81,8 @@ class upgradepath(AutoQATest):
         reponames = [reponame for reponame in autoqa.koji_utils.repoinfo.repos() if not reponame.endswith('-testing')]
         repotags = [autoqa.koji_utils.repoinfo.getrepo(reponame)['tag'] for reponame in reponames]
         repotags.sort()
-        try:
-            current_tag = repotags.index(kojitag)
-        except ValueError:
-            self.test_result = 'FAIL'
-            msg = "ERROR: Entered bad kojitag"
-            print msg
-            self.log.append(msg)
-            self.envr_list.add(matching_build['envr'])
-            raise error.TestFail
+        assert kojitag in repotags, 'Requested unsupported kojitag: %s' % kojitag
+        current_tag = repotags.index(kojitag)
 
         hi_tags = repotags[(current_tag + 1):] # tags higher than current
         low_eq_tags = repotags[:(current_tag + 1)] # tags lower or equal
@@ -150,6 +142,3 @@ class upgradepath(AutoQATest):
 
         self.summary = packages_fail
 
-        if self.test_result == 'FAIL':
-            raise error.TestFail
-
-- 
1.7.2.2



More information about the autoqa-devel mailing list