Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
47e4f0d3
Commit
47e4f0d3
authored
Jan 04, 2012
by
Marko Tibold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
We can now use @unittests.skip
parent
591bb630
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
12 deletions
+42
-12
djangorestframework/compat.py
+29
-0
djangorestframework/tests/content.py
+13
-12
No files found.
djangorestframework/compat.py
View file @
47e4f0d3
...
@@ -432,3 +432,32 @@ try:
...
@@ -432,3 +432,32 @@ try:
except
ImportError
:
except
ImportError
:
yaml
=
None
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
djangorestframework/tests/content.py
View file @
47e4f0d3
...
@@ -6,7 +6,7 @@ from django.contrib.auth.models import User
...
@@ -6,7 +6,7 @@ from django.contrib.auth.models import User
from
django.test
import
TestCase
,
Client
from
django.test
import
TestCase
,
Client
from
djangorestframework
import
status
from
djangorestframework
import
status
from
djangorestframework.authentication
import
UserLoggedInAuthentication
from
djangorestframework.authentication
import
UserLoggedInAuthentication
from
djangorestframework.compat
import
RequestFactory
from
djangorestframework.compat
import
RequestFactory
,
unittest
from
djangorestframework.mixins
import
RequestMixin
from
djangorestframework.mixins
import
RequestMixin
from
djangorestframework.parsers
import
FormParser
,
MultiPartParser
,
\
from
djangorestframework.parsers
import
FormParser
,
MultiPartParser
,
\
PlainTextParser
,
JSONParser
PlainTextParser
,
JSONParser
...
@@ -114,21 +114,22 @@ class TestContentParsing(TestCase):
...
@@ -114,21 +114,22 @@ class TestContentParsing(TestCase):
self
.
assertEqual
(
view
.
DATA
.
items
(),
form_data
.
items
())
self
.
assertEqual
(
view
.
DATA
.
items
(),
form_data
.
items
())
self
.
assertEqual
(
view
.
request
.
POST
.
items
(),
form_data
.
items
())
self
.
assertEqual
(
view
.
request
.
POST
.
items
(),
form_data
.
items
())
# def test_accessing_post_after_data_for_json(self):
@unittest.skip
(
'This test was disabled some time ago for some reason'
)
# """Ensures request.POST can be accessed after request.DATA in json request"""
def
test_accessing_post_after_data_for_json
(
self
):
# from django.utils import simplejson as json
"""Ensures request.POST can be accessed after request.DATA in json request"""
from
django.utils
import
simplejson
as
json
#
data = {'qwerty': 'uiop'}
data
=
{
'qwerty'
:
'uiop'
}
#
content = json.dumps(data)
content
=
json
.
dumps
(
data
)
#
content_type = 'application/json'
content_type
=
'application/json'
#
view = RequestMixin()
view
=
RequestMixin
()
#
view.parsers = (JSONParser,)
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
.
DATA
.
items
(),
data
.
items
())
#
self.assertEqual(view.request.POST.items(), [])
self
.
assertEqual
(
view
.
request
.
POST
.
items
(),
[])
def
test_accessing_post_after_data_for_overloaded_json
(
self
):
def
test_accessing_post_after_data_for_overloaded_json
(
self
):
"""Ensures request.POST can be accessed after request.DATA in overloaded json request"""
"""Ensures request.POST can be accessed after request.DATA in overloaded json request"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment