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