aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/tests/test_files.py
diff options
context:
space:
mode:
Diffstat (limited to 'rest_framework/tests/test_files.py')
-rw-r--r--rest_framework/tests/test_files.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/rest_framework/tests/test_files.py b/rest_framework/tests/test_files.py
index c13c38b8..78f4cf42 100644
--- a/rest_framework/tests/test_files.py
+++ b/rest_framework/tests/test_files.py
@@ -80,3 +80,16 @@ class FileSerializerTests(TestCase):
serializer = UploadedFileSerializer(data={'created': now, 'file': 'abc'})
self.assertFalse(serializer.is_valid())
self.assertEqual(serializer.errors, {'file': [errmsg]})
+
+ def test_validation_with_no_data(self):
+ """
+ Validation should still function when no data dictionary is provided.
+ """
+ now = datetime.datetime.now()
+ file = BytesIO(six.b('stuff'))
+ file.name = 'stuff.txt'
+ file.size = len(file.getvalue())
+ uploaded_file = UploadedFile(file=file, created=now)
+
+ serializer = UploadedFileSerializer(files={'file': file})
+ self.assertFalse(serializer.is_valid())