mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-23 01:57:00 +03:00
Added failing test cases for giving a DateField or DateTimeField a None value to serialize.
Signed-off-by: Kevin Stone <kevinastone@gmail.com>
This commit is contained in:
parent
751064a6fd
commit
6bea275de8
|
@ -171,6 +171,13 @@ class DateFieldTest(TestCase):
|
|||
|
||||
self.assertEqual('1984 - 07.31', result_1)
|
||||
|
||||
def test_to_native_none(self):
|
||||
"""
|
||||
Make sure from_native() returns None on None param.
|
||||
"""
|
||||
f = serializers.DateField(required=False)
|
||||
self.assertEqual(None, f.to_native(None))
|
||||
|
||||
|
||||
class DateTimeFieldTest(TestCase):
|
||||
"""
|
||||
|
@ -303,6 +310,13 @@ class DateTimeFieldTest(TestCase):
|
|||
self.assertEqual('1984 - 04:31', result_3)
|
||||
self.assertEqual('1984 - 04:31', result_4)
|
||||
|
||||
def test_to_native_none(self):
|
||||
"""
|
||||
Make sure from_native() returns None on None param.
|
||||
"""
|
||||
f = serializers.DateTimeField(required=False)
|
||||
self.assertEqual(None, f.to_native(None))
|
||||
|
||||
|
||||
class TimeFieldTest(TestCase):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue
Block a user