From 06ea872b20e466127451c0d7b12587a72cd2f523 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Fri, 15 Aug 2008 13:16:16 +0000 Subject: [PATCH] Fixed #8244: Modified the temporary directory used by file storage tests 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 --- tests/regressiontests/file_storage/tests.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/regressiontests/file_storage/tests.py b/tests/regressiontests/file_storage/tests.py index d9b0fe4f7f8..a2b6baa07b7 100644 --- a/tests/regressiontests/file_storage/tests.py +++ b/tests/regressiontests/file_storage/tests.py @@ -5,7 +5,12 @@ Tests for the file storage mechanism >>> 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 @@ SuspiciousOperation: Attempted access to '/etc/passwd' denied. ... 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 @@ u'custom_storage.2' >>> 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).