From: Mike Frysinger Date: Thu, 17 Oct 2013 05:00:56 +0000 (-0400) Subject: tests: support standard unittest.SkipTest exceptions X-Git-Tag: v2.2.8~52 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b02fab10e3ec124d1c2f0b66717451f55c3224a0;p=portage.git tests: support standard unittest.SkipTest exceptions --- diff --git a/pym/portage/tests/__init__.py b/pym/portage/tests/__init__.py index 890851b9d..6c5c4dfd5 100644 --- a/pym/portage/tests/__init__.py +++ b/pym/portage/tests/__init__.py @@ -13,6 +13,14 @@ try: except ImportError: from unittest import _TextTestResult +try: + # They added the skip framework to python-2.7. + # Drop this once we drop python-2.6 support. + unittest_skip_shims = False + import unittest.SkipTest as SkipTest # new in python-2.7 +except ImportError: + unittest_skip_shims = True + import portage from portage import os from portage import _encodings @@ -188,10 +196,14 @@ class TestCase(unittest.TestCase): except: result.addError(self, sys.exc_info()) return + ok = False try: testMethod() ok = True + except SkipTest as e: + result.addPortageSkip(self, "%s: SKIP: %s" % + (testMethod, str(e))) except self.failureException: if self.portage_skip is not None: if self.portage_skip is True: @@ -207,6 +219,7 @@ class TestCase(unittest.TestCase): raise except: result.addError(self, sys.exc_info()) + try: self.tearDown() except SystemExit: @@ -216,7 +229,8 @@ class TestCase(unittest.TestCase): except: result.addError(self, sys.exc_info()) ok = False - if ok: result.addSuccess(self) + if ok: + result.addSuccess(self) finally: result.stopTest(self) @@ -258,6 +272,16 @@ class TestCase(unittest.TestCase): if os.path.exists(path): raise self.failureException('path exists when it should not: %s' % path) +if unittest_skip_shims: + # Shim code for