summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2013-06-27 10:58:05 +0200
committerClaude Paroz <claude@2xlibre.net>2013-06-29 18:11:51 +0200
commitb6aed803b20cc7898a82fd65845e97676276f3fa (patch)
tree13f7dcefd69a067cd57a2f85ce8d26ac11f9ebd6 /tests
parentc55cb6fa4524884c8b881b255ed0bb20f5e0b26a (diff)
[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.
Diffstat (limited to 'tests')
-rw-r--r--tests/model_fields/tests.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/model_fields/tests.py b/tests/model_fields/tests.py
index ccff8b8cfa..6abeed8c42 100644
--- a/tests/model_fields/tests.py
+++ b/tests/model_fields/tests.py
@@ -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'