Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Russell Keith-Magee authored August 15, 2008
13  tests/regressiontests/file_storage/tests.py
@@ -5,7 +5,12 @@
5 5
 >>> from django.core.files.storage import FileSystemStorage
6 6
 >>> from django.core.files.base import ContentFile
7 7
 
8  
->>> temp_storage = FileSystemStorage(location=tempfile.gettempdir())
  8
+# Set up a unique temporary directory
  9
+>>> import os
  10
+>>> temp_dir = tempfile.mktemp()
  11
+>>> os.makedirs(temp_dir)
  12
+
  13
+>>> temp_storage = FileSystemStorage(location=temp_dir)
9 14
 
10 15
 # Standard file access options are available, and work as expected.
11 16
 
@@ -52,7 +57,7 @@
52 57
 ...             number += 1
53 58
 ...
54 59
 ...         return name
55  
->>> custom_storage = CustomStorage(tempfile.gettempdir())
  60
+>>> custom_storage = CustomStorage(temp_dir)
56 61
 
57 62
 >>> first = custom_storage.save('custom_storage', ContentFile('custom contents'))
58 63
 >>> first
@@ -63,6 +68,10 @@
63 68
 
64 69
 >>> custom_storage.delete(first)
65 70
 >>> custom_storage.delete(second)
  71
+
  72
+# Cleanup the temp dir
  73
+>>> os.rmdir(temp_dir)
  74
+
66 75
 """
67 76
 
68 77
 # Tests for a race condition on file saving (#4948).

0 notes on commit 06ea872

Please sign in to comment.
Something went wrong with that request. Please try again.