-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle primitive types in serializerfields
Avoid crashes because the to_python helper expects data to be provided as string.
- Loading branch information
1 parent
4aeb786
commit edd12eb
Showing
2 changed files
with
15 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from django.test import SimpleTestCase | ||
from rest_framework import serializers | ||
|
||
from phonenumber_field.serializerfields import PhoneNumberField | ||
|
||
|
||
class PhoneNumberFieldTest(SimpleTestCase): | ||
def test_int(self): | ||
class PhoneNumberSerializer(serializers.Serializer): | ||
phone = PhoneNumberField() | ||
|
||
s = PhoneNumberSerializer(data={"phone": 1}) | ||
self.assertIs(s.is_valid(), False) |