Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Refs #17215: Avoid generating 47 leftover tmp dirs during a clean tes…

…t run.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17094 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 5de31cb8cb83c33d932d5ddf76ff81506c28bdff 1 parent b835301
Karen Tracey authored November 13, 2011
3  django/contrib/formtools/tests/wizard/wizardtests/forms.py
... ...
@@ -1,3 +1,4 @@
  1
+import os
1 2
 import tempfile
2 3
 
3 4
 from django import forms
@@ -10,7 +11,7 @@
10 11
 
11 12
 from django.contrib.formtools.wizard.views import WizardView
12 13
 
13  
-temp_storage_location = tempfile.mkdtemp()
  14
+temp_storage_location = tempfile.mkdtemp(dir=os.environ.get('DJANGO_TEST_TEMP_DIR'))
14 15
 temp_storage = FileSystemStorage(location=temp_storage_location)
15 16
 
16 17
 class Page1(forms.Form):
3  tests/modeltests/model_forms/models.py
@@ -7,13 +7,14 @@
7 7
 words, most of these tests should be rewritten.
8 8
 """
9 9
 
  10
+import os
10 11
 import tempfile
11 12
 
12 13
 from django.core.files.storage import FileSystemStorage
13 14
 from django.db import models
14 15
 
15 16
 
16  
-temp_storage_dir = tempfile.mkdtemp()
  17
+temp_storage_dir = tempfile.mkdtemp(dir=os.environ['DJANGO_TEST_TEMP_DIR'])
17 18
 temp_storage = FileSystemStorage(temp_storage_dir)
18 19
 
19 20
 ARTICLE_STATUS = (
2  tests/regressiontests/admin_views/admin.py
@@ -260,7 +260,7 @@ class OldSubscriberAdmin(admin.ModelAdmin):
260 260
     actions = None
261 261
 
262 262
 
263  
-temp_storage = FileSystemStorage(tempfile.mkdtemp())
  263
+temp_storage = FileSystemStorage(tempfile.mkdtemp(dir=os.environ['DJANGO_TEST_TEMP_DIR']))
264 264
 UPLOAD_TO = os.path.join(temp_storage.location, 'test_upload')
265 265
 
266 266
 
4  tests/regressiontests/admin_views/models.py
@@ -246,7 +246,7 @@ def __unicode__(self):
246 246
         return "Primary key = %s" % self.id
247 247
 
248 248
 
249  
-temp_storage = FileSystemStorage(tempfile.mkdtemp())
  249
+temp_storage = FileSystemStorage(tempfile.mkdtemp(dir=os.environ['DJANGO_TEST_TEMP_DIR']))
250 250
 UPLOAD_TO = os.path.join(temp_storage.location, 'test_upload')
251 251
 
252 252
 
@@ -547,4 +547,4 @@ class PrePopulatedPostLargeSlug(models.Model):
547 547
     title = models.CharField(max_length=100) 
548 548
     published = models.BooleanField() 
549 549
     slug = models.SlugField(max_length=1000)
550  
-    
  550
+    
3  tests/regressiontests/forms/models.py
... ...
@@ -1,4 +1,5 @@
1 1
 # -*- coding: utf-8 -*-
  2
+import os
2 3
 import datetime
3 4
 import tempfile
4 5
 
@@ -6,7 +7,7 @@
6 7
 from django.db import models
7 8
 
8 9
 
9  
-temp_storage_location = tempfile.mkdtemp()
  10
+temp_storage_location = tempfile.mkdtemp(dir=os.environ['DJANGO_TEST_TEMP_DIR'])
10 11
 temp_storage = FileSystemStorage(location=temp_storage_location)
11 12
 
12 13
 
2  tests/regressiontests/staticfiles_tests/tests.py
@@ -100,7 +100,7 @@ class BaseCollectionTestCase(BaseStaticFilesTestCase):
100 100
     def setUp(self):
101 101
         super(BaseCollectionTestCase, self).setUp()
102 102
         self.old_root = settings.STATIC_ROOT
103  
-        settings.STATIC_ROOT = tempfile.mkdtemp()
  103
+        settings.STATIC_ROOT = tempfile.mkdtemp(dir=os.environ['DJANGO_TEST_TEMP_DIR'])
104 104
         self.run_collectstatic()
105 105
         # Use our own error handler that can handle .svn dirs on Windows
106 106
         #self.addCleanup(shutil.rmtree, settings.STATIC_ROOT,
1  tests/runtests.py
@@ -19,6 +19,7 @@
19 19
 MODEL_TEST_DIR = os.path.join(RUNTESTS_DIR, MODEL_TESTS_DIR_NAME)
20 20
 REGRESSION_TEST_DIR = os.path.join(RUNTESTS_DIR, REGRESSION_TESTS_DIR_NAME)
21 21
 TEMP_DIR = tempfile.mkdtemp(prefix='django_')
  22
+os.environ['DJANGO_TEST_TEMP_DIR'] = TEMP_DIR
22 23
 
23 24
 REGRESSION_SUBDIRS_TO_SKIP = ['locale']
24 25
 

0 notes on commit 5de31cb

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