Kaydet (Commit) 80936251 authored tarafından Claude Paroz's avatar Claude Paroz

Created import-time test temp dirs in known location

Refs #17215. In the same spirit as 5de31cb8.
üst 1d959602
import os
import tempfile import tempfile
from django.core.files.storage import FileSystemStorage from django.core.files.storage import FileSystemStorage
...@@ -5,7 +6,7 @@ from django.db import models ...@@ -5,7 +6,7 @@ from django.db import models
from django.forms import ModelForm from django.forms import ModelForm
temp_storage_dir = tempfile.mkdtemp() temp_storage_dir = tempfile.mkdtemp(dir=os.environ['DJANGO_TEST_TEMP_DIR'])
temp_storage = FileSystemStorage(temp_storage_dir) temp_storage = FileSystemStorage(temp_storage_dir)
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
and where files should be stored. and where files should be stored.
""" """
import os
import random import random
import tempfile import tempfile
...@@ -12,7 +13,7 @@ from django.db import models ...@@ -12,7 +13,7 @@ from django.db import models
from django.core.files.storage import FileSystemStorage from django.core.files.storage import FileSystemStorage
temp_storage_location = tempfile.mkdtemp() temp_storage_location = tempfile.mkdtemp(dir=os.environ['DJANGO_TEST_TEMP_DIR'])
temp_storage = FileSystemStorage(location=temp_storage_location) temp_storage = FileSystemStorage(location=temp_storage_location)
......
...@@ -23,7 +23,7 @@ from .models import FileModel ...@@ -23,7 +23,7 @@ from .models import FileModel
UNICODE_FILENAME = 'test-0123456789_中文_Orléans.jpg' UNICODE_FILENAME = 'test-0123456789_中文_Orléans.jpg'
MEDIA_ROOT = sys_tempfile.mkdtemp() MEDIA_ROOT = sys_tempfile.mkdtemp(dir=os.environ['DJANGO_TEST_TEMP_DIR'])
UPLOAD_TO = os.path.join(MEDIA_ROOT, 'test_upload') UPLOAD_TO = os.path.join(MEDIA_ROOT, 'test_upload')
......
...@@ -194,7 +194,7 @@ if Image: ...@@ -194,7 +194,7 @@ if Image:
attr_class = TestImageFieldFile attr_class = TestImageFieldFile
# Set up a temp directory for file storage. # Set up a temp directory for file storage.
temp_storage_dir = tempfile.mkdtemp() temp_storage_dir = tempfile.mkdtemp(dir=os.environ['DJANGO_TEST_TEMP_DIR'])
temp_storage = FileSystemStorage(temp_storage_dir) temp_storage = FileSystemStorage(temp_storage_dir)
temp_upload_to_dir = os.path.join(temp_storage.location, 'tests') temp_upload_to_dir = os.path.join(temp_storage.location, 'tests')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment