churchyard / rpms / python3

Forked from rpms/python3 6 years ago
Clone

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

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
f5250ec
 import logging
0c8875f
 import pprint
0c8875f
 import re
Robert Kuska a1c0d07
@@ -101,5 +102,21 @@ def expectedFailure(func):
f5250ec
         raise self.test_case.failureException(msg)
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
+
f5250ec
 class _AssertRaisesBaseContext(_BaseTestCaseContext):
0c8875f
 
Matej Stuchlik abb2ff8
     def __init__(self, expected, test_case, expected_regex=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,
Robert Kuska f2e5fa9
+                   _skipInRpmBuild)
0c8875f
 from .suite import BaseTestSuite, TestSuite
0c8875f
 from .loader import (TestLoader, defaultTestLoader, makeSuite, getTestCaseNames,
0c8875f
                      findTestCases)