diff options
| author | Marko Tibold | 2012-01-04 11:58:22 +0100 |
|---|---|---|
| committer | Marko Tibold | 2012-01-04 11:58:22 +0100 |
| commit | 47e4f0d37deb0f420e403cee6b4b4790e875d250 (patch) | |
| tree | 16a5424b8176d06ca6ab01a055e6572ecd7c7ed4 /djangorestframework/compat.py | |
| parent | 591bb630d74e8bbad42d533dc175b414ec7566a4 (diff) | |
| download | django-rest-framework-47e4f0d37deb0f420e403cee6b4b4790e875d250.tar.bz2 | |
We can now use @unittests.skip
Diffstat (limited to 'djangorestframework/compat.py')
| -rw-r--r-- | djangorestframework/compat.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/djangorestframework/compat.py b/djangorestframework/compat.py index 38119811..58ecb453 100644 --- a/djangorestframework/compat.py +++ b/djangorestframework/compat.py @@ -432,3 +432,32 @@ try: except ImportError: yaml = None +import unittest +try: + import unittest.skip +except ImportError: # python < 2.7 + from unittest import TestCase + import functools + + class SkipTest(Exception): + # Pasted from py27/lib/unittest/case.py + pass + + def skip(reason): + # Pasted from py27/lib/unittest/case.py + """ + Unconditionally skip a test. + """ + def decorator(test_item): + if not (isinstance(test_item, type) and issubclass(test_item, TestCase)): + @functools.wraps(test_item) + def skip_wrapper(*args, **kwargs): + raise SkipTest(reason) + test_item = skip_wrapper + + test_item.__unittest_skip__ = True + test_item.__unittest_skip_why__ = reason + return test_item + return decorator + + unittest.skip = skip |
