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
4b59ec27
Commit
4b59ec27
authored
Nov 23, 2016
by
Asif Saifuddin Auvi
Committed by
Tom Christie
Nov 23, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
convert tests asserts to pytest style (#4696)
parent
3e1b31bb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
13 deletions
+13
-13
tests/test_views.py
+8
-8
tests/test_viewsets.py
+5
-5
No files found.
tests/test_views.py
View file @
4b59ec27
...
...
@@ -71,8 +71,8 @@ class ClassBasedViewIntegrationTests(TestCase):
expected
=
{
'detail'
:
JSON_ERROR
}
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_400_BAD_REQUEST
)
self
.
assertEqual
(
sanitise_json_error
(
response
.
data
),
expected
)
assert
response
.
status_code
==
status
.
HTTP_400_BAD_REQUEST
assert
sanitise_json_error
(
response
.
data
)
==
expected
class
FunctionBasedViewIntegrationTests
(
TestCase
):
...
...
@@ -85,8 +85,8 @@ class FunctionBasedViewIntegrationTests(TestCase):
expected
=
{
'detail'
:
JSON_ERROR
}
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_400_BAD_REQUEST
)
self
.
assertEqual
(
sanitise_json_error
(
response
.
data
),
expected
)
assert
response
.
status_code
==
status
.
HTTP_400_BAD_REQUEST
assert
sanitise_json_error
(
response
.
data
)
==
expected
class
TestCustomExceptionHandler
(
TestCase
):
...
...
@@ -107,8 +107,8 @@ class TestCustomExceptionHandler(TestCase):
request
=
factory
.
get
(
'/'
,
content_type
=
'application/json'
)
response
=
view
(
request
)
expected
=
'Error!'
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_400_BAD_REQUEST
)
self
.
assertEqual
(
response
.
data
,
expected
)
assert
response
.
status_code
==
status
.
HTTP_400_BAD_REQUEST
assert
response
.
data
==
expected
def
test_function_based_view_exception_handler
(
self
):
view
=
error_view
...
...
@@ -116,5 +116,5 @@ class TestCustomExceptionHandler(TestCase):
request
=
factory
.
get
(
'/'
,
content_type
=
'application/json'
)
response
=
view
(
request
)
expected
=
'Error!'
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_400_BAD_REQUEST
)
self
.
assertEqual
(
response
.
data
,
expected
)
assert
response
.
status_code
==
status
.
HTTP_400_BAD_REQUEST
assert
response
.
data
==
expected
tests/test_viewsets.py
View file @
4b59ec27
...
...
@@ -21,15 +21,15 @@ class InitializeViewSetsTestCase(TestCase):
})
response
=
my_view
(
request
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
self
.
assertEqual
(
response
.
data
,
{
'ACTION'
:
'LIST'
})
assert
response
.
status_code
==
status
.
HTTP_200_OK
assert
response
.
data
==
{
'ACTION'
:
'LIST'
}
def
test_initialize_view_set_with_empty_actions
(
self
):
try
:
BasicViewSet
.
as_view
()
except
TypeError
as
e
:
self
.
assertEqual
(
str
(
e
),
"The `actions` argument must be provided "
"when calling `.as_view()` on a ViewSet. "
"For example `.as_view({'get': 'list'})`"
)
assert
str
(
e
)
==
(
"The `actions` argument must be provided "
"when calling `.as_view()` on a ViewSet. "
"For example `.as_view({'get': 'list'})`"
)
else
:
self
.
fail
(
"actions must not be empty."
)
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