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

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