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

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