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

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