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