churchyard / rpms / python38

Forked from rpms/python38 3 years ago
Clone
1fb3c04
diff --git a/Lib/unittest/__init__.py b/Lib/unittest/__init__.py
1fb3c04
index 5ff1bf3..4d63954 100644
1fb3c04
--- a/Lib/unittest/__init__.py
1fb3c04
+++ b/Lib/unittest/__init__.py
1fb3c04
@@ -58,7 +58,7 @@ __unittest = True
1fb3c04
 
1fb3c04
 from .result import TestResult
1fb3c04
 from .case import (addModuleCleanup, TestCase, FunctionTestCase, SkipTest, skip,
1fb3c04
-                   skipIf, skipUnless, expectedFailure)
1fb3c04
+                   skipIf, skipUnless, expectedFailure, _skipInRpmBuild)
1fb3c04
 from .suite import BaseTestSuite, TestSuite
1fb3c04
 from .loader import (TestLoader, defaultTestLoader, makeSuite, getTestCaseNames,
1fb3c04
                      findTestCases)
1fb3c04
diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py
1fb3c04
index a157ae8..64f912c 100644
1fb3c04
--- a/Lib/unittest/case.py
1fb3c04
+++ b/Lib/unittest/case.py
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
1fb3c04
@@ -158,6 +159,22 @@ class _BaseTestCaseContext:
1fb3c04
         msg = self.test_case._formatMessage(self.msg, standardMsg)
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):