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:08:39 +0200
commitea3fe78a9d742904f6902cdc353a11d795418105 (patch)
tree21f431110ca64805c3ed83c2becd2443b509d5a7 /tests
parentb5f709e6f4c67020bedb141b9b18c5cd1e05f829 (diff)
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.
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'