mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	[1.6.x] Fixed #20660 -- Do not try to delete an unset FieldFile
Thanks stanislas.guerra at gmail.com for the report and
Baptiste Mispelon for the review.
Backport of ea3fe78a9d from master.
			
			
This commit is contained in:
		| @@ -432,6 +432,17 @@ class FileFieldTests(unittest.TestCase): | ||||
|         field.save_form_data(d, 'else.txt') | ||||
|         self.assertEqual(d.myfile, 'else.txt') | ||||
|  | ||||
|     def test_delete_when_file_unset(self): | ||||
|         """ | ||||
|         Calling delete on an unset FileField should not call the file deletion | ||||
|         process, but fail silently (#20660). | ||||
|         """ | ||||
|         d = Document() | ||||
|         try: | ||||
|             d.myfile.delete() | ||||
|         except OSError: | ||||
|             self.fail("Deleting an unset FileField should not raise OSError.") | ||||
|  | ||||
|  | ||||
| class BinaryFieldTests(test.TestCase): | ||||
|     binary_data = b'\x00\x46\xFE' | ||||
|   | ||||
		Reference in New Issue
	
	Block a user