Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #8244: Modified the temporary directory used by file storage te…

…sts so that mutliple test runs can be performed in parallel without conflict.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8376 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 06ea872b20e466127451c0d7b12587a72cd2f523 1 parent 6eb0dea
@freakboy3742 freakboy3742 authored
Showing with 11 additions and 2 deletions.
  1. +11 −2 tests/regressiontests/file_storage/tests.py
View
13 tests/regressiontests/file_storage/tests.py
@@ -5,7 +5,12 @@
>>> from django.core.files.storage import FileSystemStorage
>>> from django.core.files.base import ContentFile
->>> temp_storage = FileSystemStorage(location=tempfile.gettempdir())
+# Set up a unique temporary directory
+>>> import os
+>>> temp_dir = tempfile.mktemp()
+>>> os.makedirs(temp_dir)
+
+>>> temp_storage = FileSystemStorage(location=temp_dir)
# Standard file access options are available, and work as expected.
@@ -52,7 +57,7 @@
... number += 1
...
... return name
->>> custom_storage = CustomStorage(tempfile.gettempdir())
+>>> custom_storage = CustomStorage(temp_dir)
>>> first = custom_storage.save('custom_storage', ContentFile('custom contents'))
>>> first
@@ -63,6 +68,10 @@
>>> custom_storage.delete(first)
>>> custom_storage.delete(second)
+
+# Cleanup the temp dir
+>>> os.rmdir(temp_dir)
+
"""
# Tests for a race condition on file saving (#4948).
Please sign in to comment.
Something went wrong with that request. Please try again.