mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
Made a set of small test changes to avoid leaving temp files hanging around after running the test suite. First, fixed a couple of places where temp dirs were (or could be) created without later being deleted. Second, added a missing close() before unlink() since Windows raises an error on an attempt to remove an open file. Finally, in the file_uploads tests, avoided opening-by-name temporary files that we already have a descriptor for. Doing additional opens seems to run afoul of the Windows issue with deleting open files, so it generally works better to just seek back to 0 instead of calling open multiple times.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10406 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
6d5492630d
commit
d0c897d660
5 changed files with 30 additions and 12 deletions
|
@ -5,9 +5,6 @@ from django.db import models
|
|||
from django.core.files.storage import FileSystemStorage
|
||||
from django.core.files.base import ContentFile
|
||||
|
||||
temp_storage_dir = tempfile.mkdtemp()
|
||||
temp_storage = FileSystemStorage(temp_storage_dir)
|
||||
|
||||
# Test for correct behavior of width_field/height_field.
|
||||
# Of course, we can't run this without PIL.
|
||||
|
||||
|
@ -20,6 +17,9 @@ except ImportError:
|
|||
|
||||
# If we have PIL, do these tests
|
||||
if Image:
|
||||
temp_storage_dir = tempfile.mkdtemp()
|
||||
temp_storage = FileSystemStorage(temp_storage_dir)
|
||||
|
||||
class Person(models.Model):
|
||||
name = models.CharField(max_length=50)
|
||||
mugshot = models.ImageField(storage=temp_storage, upload_to='tests',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue