summaryrefslogtreecommitdiff
path: root/tests/model_forms
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2024-07-21 07:44:38 +0200
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2024-07-22 08:51:01 +0200
commitb06cf62c88218292209427f67dc679761d7d24fc (patch)
treea7238b63bb4c1565719d7de726b55a0292ab8112 /tests/model_forms
parent2ff917fd06e5155920e085837a2cfab73604e3e4 (diff)
Cleaned up temporary test directories in tests.
Diffstat (limited to 'tests/model_forms')
-rw-r--r--tests/model_forms/models.py2
-rw-r--r--tests/model_forms/tests.py8
2 files changed, 9 insertions, 1 deletions
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