Blame SOURCES/00132-add-rpmbuild-hooks-to-unittest.patch

72be67
diff -up Python-2.7.2/Lib/unittest/case.py.add-rpmbuild-hooks-to-unittest Python-2.7.2/Lib/unittest/case.py
72be67
--- Python-2.7.2/Lib/unittest/case.py.add-rpmbuild-hooks-to-unittest	2011-09-08 14:45:47.677169191 -0400
72be67
+++ Python-2.7.2/Lib/unittest/case.py	2011-09-08 16:01:36.287858159 -0400
72be67
@@ -1,6 +1,7 @@
72be67
 """Test case implementation"""
72be67
 
72be67
 import collections
72be67
+import os
72be67
 import sys
72be67
 import functools
72be67
 import difflib
72be67
@@ -94,6 +95,43 @@ def expectedFailure(func):
72be67
     return wrapper
72be67
 
72be67
 
72be67
+# Non-standard/downstream-only hooks for handling issues with specific test
72be67
+# cases:
72be67
+
72be67
+def _skipInRpmBuild(reason):
72be67
+    """
72be67
+    Non-standard/downstream-only decorator for marking a specific unit test
72be67
+    to be skipped when run within the %check of an rpmbuild.
72be67
+
72be67
+    Specifically, this takes effect when WITHIN_PYTHON_RPM_BUILD is set within
72be67
+    the environment, and has no effect otherwise.
72be67
+    """
72be67
+    if 'WITHIN_PYTHON_RPM_BUILD' in os.environ:
72be67
+        return skip(reason)
72be67
+    else:
72be67
+        return _id
72be67
+
72be67
+def _expectedFailureInRpmBuild(func):
72be67
+    """
72be67
+    Non-standard/downstream-only decorator for marking a specific unit test
72be67
+    as expected to fail within the %check of an rpmbuild.
72be67
+
72be67
+    Specifically, this takes effect when WITHIN_PYTHON_RPM_BUILD is set within
72be67
+    the environment, and has no effect otherwise.
72be67
+    """
72be67
+    @functools.wraps(func)
72be67
+    def wrapper(*args, **kwargs):
72be67
+        if 'WITHIN_PYTHON_RPM_BUILD' in os.environ:
72be67
+            try:
72be67
+                func(*args, **kwargs)
72be67
+            except Exception:
72be67
+                raise _ExpectedFailure(sys.exc_info())
72be67
+            raise _UnexpectedSuccess
72be67
+        else:
72be67
+            # Call directly:
72be67
+            func(*args, **kwargs)
72be67
+    return wrapper
72be67
+
72be67
 class _AssertRaisesContext(object):
72be67
     """A context manager used to implement TestCase.assertRaises* methods."""
72be67
 
72be67
diff -up Python-2.7.2/Lib/unittest/__init__.py.add-rpmbuild-hooks-to-unittest Python-2.7.2/Lib/unittest/__init__.py
72be67
--- Python-2.7.2/Lib/unittest/__init__.py.add-rpmbuild-hooks-to-unittest	2011-09-08 14:59:39.534112310 -0400
72be67
+++ Python-2.7.2/Lib/unittest/__init__.py	2011-09-08 15:07:09.191081562 -0400
72be67
@@ -57,7 +57,8 @@ __unittest = True
72be67
 
72be67
 from .result import TestResult
72be67
 from .case import (TestCase, FunctionTestCase, SkipTest, skip, skipIf,
72be67
-                   skipUnless, expectedFailure)
72be67
+                   skipUnless, expectedFailure,
72be67
+                   _skipInRpmBuild, _expectedFailureInRpmBuild)
72be67
 from .suite import BaseTestSuite, TestSuite
72be67
 from .loader import (TestLoader, defaultTestLoader, makeSuite, getTestCaseNames,
72be67
                      findTestCases)