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
1f75ffc7
Commit
1f75ffc7
authored
Sep 12, 2014
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Access validation messages in a way thats compatible with 1.4, 1.5
parent
0ac52e08
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
tests/test_relations.py
+4
-4
No files found.
tests/test_relations.py
View file @
1f75ffc7
...
...
@@ -32,13 +32,13 @@ class TestPrimaryKeyRelatedField(APISimpleTestCase):
def
test_pk_related_lookup_does_not_exist
(
self
):
with
pytest
.
raises
(
ValidationError
)
as
excinfo
:
self
.
field
.
to_internal_value
(
4
)
msg
=
excinfo
.
value
.
message
msg
=
excinfo
.
value
.
message
s
[
0
]
assert
msg
==
"Invalid pk '4' - object does not exist."
def
test_pk_related_lookup_invalid_type
(
self
):
with
pytest
.
raises
(
ValidationError
)
as
excinfo
:
self
.
field
.
to_internal_value
(
BadType
())
msg
=
excinfo
.
value
.
message
msg
=
excinfo
.
value
.
message
s
[
0
]
assert
msg
==
'Incorrect type. Expected pk value, received BadType.'
def
test_pk_representation
(
self
):
...
...
@@ -122,13 +122,13 @@ class TestSlugRelatedField(APISimpleTestCase):
def
test_slug_related_lookup_does_not_exist
(
self
):
with
pytest
.
raises
(
ValidationError
)
as
excinfo
:
self
.
field
.
to_internal_value
(
'doesnotexist'
)
msg
=
excinfo
.
value
.
message
msg
=
excinfo
.
value
.
message
s
[
0
]
assert
msg
==
'Object with name=doesnotexist does not exist.'
def
test_slug_related_lookup_invalid_type
(
self
):
with
pytest
.
raises
(
ValidationError
)
as
excinfo
:
self
.
field
.
to_internal_value
(
BadType
())
msg
=
excinfo
.
value
.
message
msg
=
excinfo
.
value
.
message
s
[
0
]
assert
msg
==
'Invalid value.'
def
test_representation
(
self
):
...
...
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