churchyard / rpms / python38

Forked from rpms/python38 a year ago
Clone
1fb3c0
diff --git a/Lib/unittest/__init__.py b/Lib/unittest/__init__.py
1fb3c0
index 5ff1bf3..4d63954 100644
1fb3c0
--- a/Lib/unittest/__init__.py
1fb3c0
+++ b/Lib/unittest/__init__.py
1fb3c0
@@ -58,7 +58,7 @@ __unittest = True
1fb3c0
 
1fb3c0
 from .result import TestResult
1fb3c0
 from .case import (addModuleCleanup, TestCase, FunctionTestCase, SkipTest, skip,
1fb3c0
-                   skipIf, skipUnless, expectedFailure)
1fb3c0
+                   skipIf, skipUnless, expectedFailure, _skipInRpmBuild)
1fb3c0
 from .suite import BaseTestSuite, TestSuite
1fb3c0
 from .loader import (TestLoader, defaultTestLoader, makeSuite, getTestCaseNames,
1fb3c0
                      findTestCases)
1fb3c0
diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py
1fb3c0
index a157ae8..64f912c 100644
1fb3c0
--- a/Lib/unittest/case.py
1fb3c0
+++ b/Lib/unittest/case.py
0c8875
@@ -3,6 +3,7 @@
0c8875
 import sys
0c8875
 import functools
0c8875
 import difflib
0c8875
+import os
f5250e
 import logging
0c8875
 import pprint
0c8875
 import re
1fb3c0
@@ -158,6 +159,22 @@ class _BaseTestCaseContext:
1fb3c0
         msg = self.test_case._formatMessage(self.msg, standardMsg)
f5250e
         raise self.test_case.failureException(msg)
0c8875
 
0c8875
+# Non-standard/downstream-only hooks for handling issues with specific test
0c8875
+# cases:
0c8875
+
0c8875
+def _skipInRpmBuild(reason):
0c8875
+    """
0c8875
+    Non-standard/downstream-only decorator for marking a specific unit test
0c8875
+    to be skipped when run within the %check of an rpmbuild.
0c8875
+
0c8875
+    Specifically, this takes effect when WITHIN_PYTHON_RPM_BUILD is set within
0c8875
+    the environment, and has no effect otherwise.
0c8875
+    """
0c8875
+    if 'WITHIN_PYTHON_RPM_BUILD' in os.environ:
0c8875
+        return skip(reason)
0c8875
+    else:
0c8875
+        return _id
0c8875
+
f5250e
 class _AssertRaisesBaseContext(_BaseTestCaseContext):
0c8875
 
Matej Stuchlik abb2ff
     def __init__(self, expected, test_case, expected_regex=None):