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

8dc7a2
diff -up Python-3.2.2/Lib/unittest/case.py.add-rpmbuild-hooks-to-unittest Python-3.2.2/Lib/unittest/case.py
8dc7a2
--- Python-3.2.2/Lib/unittest/case.py.add-rpmbuild-hooks-to-unittest	2011-09-03 12:16:44.000000000 -0400
8dc7a2
+++ Python-3.2.2/Lib/unittest/case.py	2011-09-09 06:35:16.365568382 -0400
8dc7a2
@@ -3,6 +3,7 @@
8dc7a2
 import sys
8dc7a2
 import functools
8dc7a2
 import difflib
8dc7a2
+import os
8dc7a2
 import logging
8dc7a2
 import pprint
8dc7a2
 import re
8dc7a2
@@ -101,5 +102,42 @@ def expectedFailure(func):
8dc7a2
         raise self.test_case.failureException(msg)
8dc7a2
 
8dc7a2
+# Non-standard/downstream-only hooks for handling issues with specific test
8dc7a2
+# cases:
8dc7a2
+
8dc7a2
+def _skipInRpmBuild(reason):
8dc7a2
+    """
8dc7a2
+    Non-standard/downstream-only decorator for marking a specific unit test
8dc7a2
+    to be skipped when run within the %check of an rpmbuild.
8dc7a2
+
8dc7a2
+    Specifically, this takes effect when WITHIN_PYTHON_RPM_BUILD is set within
8dc7a2
+    the environment, and has no effect otherwise.
8dc7a2
+    """
8dc7a2
+    if 'WITHIN_PYTHON_RPM_BUILD' in os.environ:
8dc7a2
+        return skip(reason)
8dc7a2
+    else:
8dc7a2
+        return _id
8dc7a2
+
8dc7a2
+def _expectedFailureInRpmBuild(func):
8dc7a2
+    """
8dc7a2
+    Non-standard/downstream-only decorator for marking a specific unit test
8dc7a2
+    as expected to fail within the %check of an rpmbuild.
8dc7a2
+
8dc7a2
+    Specifically, this takes effect when WITHIN_PYTHON_RPM_BUILD is set within
8dc7a2
+    the environment, and has no effect otherwise.
8dc7a2
+    """
8dc7a2
+    @functools.wraps(func)
8dc7a2
+    def wrapper(*args, **kwargs):
8dc7a2
+        if 'WITHIN_PYTHON_RPM_BUILD' in os.environ:
8dc7a2
+            try:
8dc7a2
+                func(*args, **kwargs)
8dc7a2
+            except Exception:
8dc7a2
+                raise _ExpectedFailure(sys.exc_info())
8dc7a2
+            raise _UnexpectedSuccess
8dc7a2
+        else:
8dc7a2
+            # Call directly:
8dc7a2
+            func(*args, **kwargs)
8dc7a2
+    return wrapper
8dc7a2
+
8dc7a2
 class _AssertRaisesBaseContext(_BaseTestCaseContext):
8dc7a2
 
8dc7a2
     def __init__(self, expected, test_case, expected_regex=None):
8dc7a2
diff -up Python-3.2.2/Lib/unittest/__init__.py.add-rpmbuild-hooks-to-unittest Python-3.2.2/Lib/unittest/__init__.py
8dc7a2
--- Python-3.2.2/Lib/unittest/__init__.py.add-rpmbuild-hooks-to-unittest	2011-09-03 12:16:44.000000000 -0400
8dc7a2
+++ Python-3.2.2/Lib/unittest/__init__.py	2011-09-09 06:35:16.366568382 -0400
8dc7a2
@@ -57,7 +57,8 @@ __unittest = True
8dc7a2
 
8dc7a2
 from .result import TestResult
8dc7a2
 from .case import (TestCase, FunctionTestCase, SkipTest, skip, skipIf,
8dc7a2
-                   skipUnless, expectedFailure)
8dc7a2
+                   skipUnless, expectedFailure,
8dc7a2
+                   _skipInRpmBuild, _expectedFailureInRpmBuild)
8dc7a2
 from .suite import BaseTestSuite, TestSuite
8dc7a2
 from .loader import (TestLoader, defaultTestLoader, makeSuite, getTestCaseNames,
8dc7a2
                      findTestCases)