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
f1016441
Commit
f1016441
authored
Feb 11, 2014
by
Carlton Gibson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test and fix for #1210. World's lowest hanging fruit.
parent
9a767c21
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
2 deletions
+10
-2
rest_framework/fields.py
+2
-1
rest_framework/tests/test_fields.py
+8
-1
No files found.
rest_framework/fields.py
View file @
f1016441
...
@@ -477,7 +477,8 @@ class URLField(CharField):
...
@@ -477,7 +477,8 @@ class URLField(CharField):
type_label
=
'url'
type_label
=
'url'
def
__init__
(
self
,
**
kwargs
):
def
__init__
(
self
,
**
kwargs
):
kwargs
[
'validators'
]
=
[
validators
.
URLValidator
()]
if
not
'validators'
in
kwargs
:
kwargs
[
'validators'
]
=
[
validators
.
URLValidator
()]
super
(
URLField
,
self
)
.
__init__
(
**
kwargs
)
super
(
URLField
,
self
)
.
__init__
(
**
kwargs
)
...
...
rest_framework/tests/test_fields.py
View file @
f1016441
...
@@ -860,7 +860,9 @@ class SlugFieldTests(TestCase):
...
@@ -860,7 +860,9 @@ class SlugFieldTests(TestCase):
class
URLFieldTests
(
TestCase
):
class
URLFieldTests
(
TestCase
):
"""
"""
Tests for URLField attribute values
Tests for URLField attribute values.
(Includes test for #1210, checking that validators can be overridden.)
"""
"""
class
URLFieldModel
(
RESTFrameworkModel
):
class
URLFieldModel
(
RESTFrameworkModel
):
...
@@ -902,6 +904,11 @@ class URLFieldTests(TestCase):
...
@@ -902,6 +904,11 @@ class URLFieldTests(TestCase):
self
.
assertEqual
(
getattr
(
serializer
.
fields
[
'url_field'
],
self
.
assertEqual
(
getattr
(
serializer
.
fields
[
'url_field'
],
'max_length'
),
20
)
'max_length'
),
20
)
def
test_validators_can_be_overridden
(
self
):
url_field
=
serializers
.
URLField
(
validators
=
[])
validators
=
url_field
.
validators
self
.
assertEqual
([],
validators
,
'Passing `validators` kwarg should have overridden default validators'
)
class
FieldMetadata
(
TestCase
):
class
FieldMetadata
(
TestCase
):
def
setUp
(
self
):
def
setUp
(
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