mirror of
				https://github.com/django/django.git
				synced 2025-10-26 07:06:08 +00:00 
			
		
		
		
	Refs #17215: Avoid generating 47 leftover tmp dirs during a clean test run.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17094 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
		| @@ -1,3 +1,4 @@ | ||||
| import os | ||||
| import tempfile | ||||
|  | ||||
| from django import forms | ||||
| @@ -10,7 +11,7 @@ from django.contrib.auth.models import User | ||||
|  | ||||
| from django.contrib.formtools.wizard.views import WizardView | ||||
|  | ||||
| temp_storage_location = tempfile.mkdtemp() | ||||
| temp_storage_location = tempfile.mkdtemp(dir=os.environ.get('DJANGO_TEST_TEMP_DIR')) | ||||
| temp_storage = FileSystemStorage(location=temp_storage_location) | ||||
|  | ||||
| class Page1(forms.Form): | ||||
|   | ||||
| @@ -7,13 +7,14 @@ and the examples are probably a poor fit for the ``ModelForm`` syntax. In other | ||||
| words, most of these tests should be rewritten. | ||||
| """ | ||||
|  | ||||
| import os | ||||
| import tempfile | ||||
|  | ||||
| from django.core.files.storage import FileSystemStorage | ||||
| from django.db import models | ||||
|  | ||||
|  | ||||
| temp_storage_dir = tempfile.mkdtemp() | ||||
| temp_storage_dir = tempfile.mkdtemp(dir=os.environ['DJANGO_TEST_TEMP_DIR']) | ||||
| temp_storage = FileSystemStorage(temp_storage_dir) | ||||
|  | ||||
| ARTICLE_STATUS = ( | ||||
|   | ||||
| @@ -260,7 +260,7 @@ class OldSubscriberAdmin(admin.ModelAdmin): | ||||
|     actions = None | ||||
|  | ||||
|  | ||||
| temp_storage = FileSystemStorage(tempfile.mkdtemp()) | ||||
| temp_storage = FileSystemStorage(tempfile.mkdtemp(dir=os.environ['DJANGO_TEST_TEMP_DIR'])) | ||||
| UPLOAD_TO = os.path.join(temp_storage.location, 'test_upload') | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -246,7 +246,7 @@ class EmptyModel(models.Model): | ||||
|         return "Primary key = %s" % self.id | ||||
|  | ||||
|  | ||||
| temp_storage = FileSystemStorage(tempfile.mkdtemp()) | ||||
| temp_storage = FileSystemStorage(tempfile.mkdtemp(dir=os.environ['DJANGO_TEST_TEMP_DIR'])) | ||||
| UPLOAD_TO = os.path.join(temp_storage.location, 'test_upload') | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -1,4 +1,5 @@ | ||||
| # -*- coding: utf-8 -*- | ||||
| import os | ||||
| import datetime | ||||
| import tempfile | ||||
|  | ||||
| @@ -6,7 +7,7 @@ from django.core.files.storage import FileSystemStorage | ||||
| from django.db import models | ||||
|  | ||||
|  | ||||
| temp_storage_location = tempfile.mkdtemp() | ||||
| temp_storage_location = tempfile.mkdtemp(dir=os.environ['DJANGO_TEST_TEMP_DIR']) | ||||
| temp_storage = FileSystemStorage(location=temp_storage_location) | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -100,7 +100,7 @@ class BaseCollectionTestCase(BaseStaticFilesTestCase): | ||||
|     def setUp(self): | ||||
|         super(BaseCollectionTestCase, self).setUp() | ||||
|         self.old_root = settings.STATIC_ROOT | ||||
|         settings.STATIC_ROOT = tempfile.mkdtemp() | ||||
|         settings.STATIC_ROOT = tempfile.mkdtemp(dir=os.environ['DJANGO_TEST_TEMP_DIR']) | ||||
|         self.run_collectstatic() | ||||
|         # Use our own error handler that can handle .svn dirs on Windows | ||||
|         #self.addCleanup(shutil.rmtree, settings.STATIC_ROOT, | ||||
|   | ||||
| @@ -19,6 +19,7 @@ CONTRIB_DIR = os.path.dirname(contrib.__file__) | ||||
| MODEL_TEST_DIR = os.path.join(RUNTESTS_DIR, MODEL_TESTS_DIR_NAME) | ||||
| REGRESSION_TEST_DIR = os.path.join(RUNTESTS_DIR, REGRESSION_TESTS_DIR_NAME) | ||||
| TEMP_DIR = tempfile.mkdtemp(prefix='django_') | ||||
| os.environ['DJANGO_TEST_TEMP_DIR'] = TEMP_DIR | ||||
|  | ||||
| REGRESSION_SUBDIRS_TO_SKIP = ['locale'] | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user