mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
Fixed #18515 -- Conditionally regenerated filename in FileField validation
When a FileField value has been saved, a new validation should not regenerate a new filename when checking the length. Refs #9893.
This commit is contained in:
parent
b6c356b7bb
commit
05d333ba3b
4 changed files with 24 additions and 19 deletions
|
@ -365,15 +365,3 @@ class FileFieldTests(unittest.TestCase):
|
|||
field = d._meta.get_field('myfile')
|
||||
field.save_form_data(d, 'else.txt')
|
||||
self.assertEqual(d.myfile, 'else.txt')
|
||||
|
||||
def test_max_length(self):
|
||||
"""
|
||||
Test that FileField validates the length of the generated file name
|
||||
that will be stored in the database. Regression for #9893.
|
||||
|
||||
"""
|
||||
# upload_to = 'unused', so file names are saved as 'unused/xxxxx'.
|
||||
# max_length = 100, so names longer than 93 characters are rejected.
|
||||
Document(myfile=93 * 'x').full_clean()
|
||||
with self.assertRaises(ValidationError):
|
||||
Document(myfile=94 * 'x').full_clean()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue