aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarko Tibold2012-01-04 11:58:22 +0100
committerMarko Tibold2012-01-04 11:58:22 +0100
commit47e4f0d37deb0f420e403cee6b4b4790e875d250 (patch)
tree16a5424b8176d06ca6ab01a055e6572ecd7c7ed4
parent591bb630d74e8bbad42d533dc175b414ec7566a4 (diff)
downloaddjango-rest-framework-47e4f0d37deb0f420e403cee6b4b4790e875d250.tar.bz2
We can now use @unittests.skip
-rw-r--r--djangorestframework/compat.py29
-rw-r--r--djangorestframework/tests/content.py25
2 files changed, 42 insertions, 12 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
diff --git a/djangorestframework/tests/content.py b/djangorestframework/tests/content.py
index 048586c8..47dfce80 100644
--- a/djangorestframework/tests/content.py
+++ b/djangorestframework/tests/content.py
@@ -6,7 +6,7 @@ from django.contrib.auth.models import User
from django.test import TestCase, Client
from djangorestframework import status
from djangorestframework.authentication import UserLoggedInAuthentication
-from djangorestframework.compat import RequestFactory
+from djangorestframework.compat import RequestFactory, unittest
from djangorestframework.mixins import RequestMixin
from djangorestframework.parsers import FormParser, MultiPartParser, \
PlainTextParser, JSONParser
@@ -114,21 +114,22 @@ class TestContentParsing(TestCase):
self.assertEqual(view.DATA.items(), form_data.items())
self.assertEqual(view.request.POST.items(), form_data.items())
- # def test_accessing_post_after_data_for_json(self):
- # """Ensures request.POST can be accessed after request.DATA in json request"""
- # from django.utils import simplejson as json
+ @unittest.skip('This test was disabled some time ago for some reason')
+ def test_accessing_post_after_data_for_json(self):
+ """Ensures request.POST can be accessed after request.DATA in json request"""
+ from django.utils import simplejson as json
- # data = {'qwerty': 'uiop'}
- # content = json.dumps(data)
- # content_type = 'application/json'
+ data = {'qwerty': 'uiop'}
+ content = json.dumps(data)
+ content_type = 'application/json'
- # view = RequestMixin()
- # view.parsers = (JSONParser,)
+ view = RequestMixin()
+ view.parsers = (JSONParser,)
- # view.request = self.req.post('/', content, content_type=content_type)
+ view.request = self.req.post('/', content, content_type=content_type)
- # self.assertEqual(view.DATA.items(), data.items())
- # self.assertEqual(view.request.POST.items(), [])
+ self.assertEqual(view.DATA.items(), data.items())
+ self.assertEqual(view.request.POST.items(), [])
def test_accessing_post_after_data_for_overloaded_json(self):
"""Ensures request.POST can be accessed after request.DATA in overloaded json request"""