diff --git a/tests/forms_tests/tests/tests.py b/tests/forms_tests/tests/tests.py index 196085ceb2..38735bfb78 100644 --- a/tests/forms_tests/tests/tests.py +++ b/tests/forms_tests/tests/tests.py @@ -259,6 +259,7 @@ class FormsModelTestCase(TestCase): m.file.name, "tests/\u6211\u96bb\u6c23\u588a\u8239\u88dd\u6eff\u6652\u9c54.txt", ) + m.file.delete() m.delete() def test_boundary_conditions(self): diff --git a/tests/model_forms/models.py b/tests/model_forms/models.py index c28461d862..f9441a4c77 100644 --- a/tests/model_forms/models.py +++ b/tests/model_forms/models.py @@ -135,7 +135,7 @@ class WriterProfile(models.Model): class Document(models.Model): - myfile = models.FileField(upload_to="unused", blank=True) + myfile = models.FileField(storage=temp_storage, upload_to="unused", blank=True) class TextFile(models.Model): diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py index c6e12e1aab..3c4c510440 100644 --- a/tests/model_forms/tests.py +++ b/tests/model_forms/tests.py @@ -1,5 +1,6 @@ import datetime import os +import shutil from decimal import Decimal from unittest import mock, skipUnless @@ -72,6 +73,7 @@ from .models import ( Triple, Writer, WriterProfile, + temp_storage_dir, test_images, ) @@ -2482,6 +2484,12 @@ class ModelOneToOneFieldTests(TestCase): class FileAndImageFieldTests(TestCase): + def setUp(self): + if os.path.exists(temp_storage_dir): + shutil.rmtree(temp_storage_dir) + os.mkdir(temp_storage_dir) + self.addCleanup(shutil.rmtree, temp_storage_dir) + def test_clean_false(self): """ If the ``clean`` method on a non-required FileField receives False as