summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2008-10-10 20:14:52 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2008-10-10 20:14:52 +0000
commita47f32449a5e93c16665926e7d3fba2c45d5a06f (patch)
treeb168095653f73d776e3f02d1c6115bf820f2c31f
parent194de934ffd9317080abf733eb76edb33eec8c49 (diff)
[1.0.X] Be nice to buildbots: switched `modeltests/files` to use a proper isolated directory for file storage
Backport of r9222 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9223 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--tests/modeltests/files/models.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/tests/modeltests/files/models.py b/tests/modeltests/files/models.py
index c9cfc357c3..3df3122cdb 100644
--- a/tests/modeltests/files/models.py
+++ b/tests/modeltests/files/models.py
@@ -5,14 +5,15 @@
and where files should be stored.
"""
+import shutil
import tempfile
-
from django.db import models
from django.core.files.base import ContentFile
from django.core.files.storage import FileSystemStorage
from django.core.cache import cache
-temp_storage = FileSystemStorage(location=tempfile.gettempdir())
+temp_storage_location = tempfile.mkdtemp()
+temp_storage = FileSystemStorage(location=temp_storage_location)
# Write out a file to be used as default content
temp_storage.save('tests/default.txt', ContentFile('default content'))
@@ -109,10 +110,10 @@ ValueError: The 'normal' attribute has no file associated with it.
>>> obj4.random
<FieldFile: .../random_file>
-# Clean up the temporary files.
-
+# Clean up the temporary files and dir.
>>> obj1.normal.delete()
>>> obj2.normal.delete()
>>> obj3.default.delete()
>>> obj4.random.delete()
+>>> shutil.rmtree(temp_storage_location)
"""}