|
|
23b3e9 |
diff -up Python-2.7.2/Lib/unittest/case.py.add-rpmbuild-hooks-to-unittest Python-2.7.2/Lib/unittest/case.py
|
|
|
23b3e9 |
--- Python-2.7.2/Lib/unittest/case.py.add-rpmbuild-hooks-to-unittest 2011-09-08 14:45:47.677169191 -0400
|
|
|
23b3e9 |
+++ Python-2.7.2/Lib/unittest/case.py 2011-09-08 16:01:36.287858159 -0400
|
|
|
23b3e9 |
@@ -1,6 +1,7 @@
|
|
|
23b3e9 |
"""Test case implementation"""
|
|
|
23b3e9 |
|
|
|
23b3e9 |
import collections
|
|
|
23b3e9 |
+import os
|
|
|
23b3e9 |
import sys
|
|
|
23b3e9 |
import functools
|
|
|
23b3e9 |
import difflib
|
|
|
23b3e9 |
@@ -94,6 +95,43 @@ def expectedFailure(func):
|
|
|
23b3e9 |
return wrapper
|
|
|
23b3e9 |
|
|
|
23b3e9 |
|
|
|
23b3e9 |
+# Non-standard/downstream-only hooks for handling issues with specific test
|
|
|
23b3e9 |
+# cases:
|
|
|
23b3e9 |
+
|
|
|
23b3e9 |
+def _skipInRpmBuild(reason):
|
|
|
23b3e9 |
+ """
|
|
|
23b3e9 |
+ Non-standard/downstream-only decorator for marking a specific unit test
|
|
|
23b3e9 |
+ to be skipped when run within the %check of an rpmbuild.
|
|
|
23b3e9 |
+
|
|
|
23b3e9 |
+ Specifically, this takes effect when WITHIN_PYTHON_RPM_BUILD is set within
|
|
|
23b3e9 |
+ the environment, and has no effect otherwise.
|
|
|
23b3e9 |
+ """
|
|
|
23b3e9 |
+ if 'WITHIN_PYTHON_RPM_BUILD' in os.environ:
|
|
|
23b3e9 |
+ return skip(reason)
|
|
|
23b3e9 |
+ else:
|
|
|
23b3e9 |
+ return _id
|
|
|
23b3e9 |
+
|
|
|
23b3e9 |
+def _expectedFailureInRpmBuild(func):
|
|
|
23b3e9 |
+ """
|
|
|
23b3e9 |
+ Non-standard/downstream-only decorator for marking a specific unit test
|
|
|
23b3e9 |
+ as expected to fail within the %check of an rpmbuild.
|
|
|
23b3e9 |
+
|
|
|
23b3e9 |
+ Specifically, this takes effect when WITHIN_PYTHON_RPM_BUILD is set within
|
|
|
23b3e9 |
+ the environment, and has no effect otherwise.
|
|
|
23b3e9 |
+ """
|
|
|
23b3e9 |
+ @functools.wraps(func)
|
|
|
23b3e9 |
+ def wrapper(*args, **kwargs):
|
|
|
23b3e9 |
+ if 'WITHIN_PYTHON_RPM_BUILD' in os.environ:
|
|
|
23b3e9 |
+ try:
|
|
|
23b3e9 |
+ func(*args, **kwargs)
|
|
|
23b3e9 |
+ except Exception:
|
|
|
23b3e9 |
+ raise _ExpectedFailure(sys.exc_info())
|
|
|
23b3e9 |
+ raise _UnexpectedSuccess
|
|
|
23b3e9 |
+ else:
|
|
|
23b3e9 |
+ # Call directly:
|
|
|
23b3e9 |
+ func(*args, **kwargs)
|
|
|
23b3e9 |
+ return wrapper
|
|
|
23b3e9 |
+
|
|
|
23b3e9 |
class _AssertRaisesContext(object):
|
|
|
23b3e9 |
"""A context manager used to implement TestCase.assertRaises* methods."""
|
|
|
23b3e9 |
|
|
|
23b3e9 |
diff -up Python-2.7.2/Lib/unittest/__init__.py.add-rpmbuild-hooks-to-unittest Python-2.7.2/Lib/unittest/__init__.py
|
|
|
23b3e9 |
--- Python-2.7.2/Lib/unittest/__init__.py.add-rpmbuild-hooks-to-unittest 2011-09-08 14:59:39.534112310 -0400
|
|
|
23b3e9 |
+++ Python-2.7.2/Lib/unittest/__init__.py 2011-09-08 15:07:09.191081562 -0400
|
|
|
23b3e9 |
@@ -57,7 +57,8 @@ __unittest = True
|
|
|
23b3e9 |
|
|
|
23b3e9 |
from .result import TestResult
|
|
|
23b3e9 |
from .case import (TestCase, FunctionTestCase, SkipTest, skip, skipIf,
|
|
|
23b3e9 |
- skipUnless, expectedFailure)
|
|
|
23b3e9 |
+ skipUnless, expectedFailure,
|
|
|
23b3e9 |
+ _skipInRpmBuild, _expectedFailureInRpmBuild)
|
|
|
23b3e9 |
from .suite import BaseTestSuite, TestSuite
|
|
|
23b3e9 |
from .loader import (TestLoader, defaultTestLoader, makeSuite, getTestCaseNames,
|
|
|
23b3e9 |
findTestCases)
|