1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +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:
Karen Tracey
2009-04-05 20:59:20 +00:00
parent 6d5492630d
commit d0c897d660
5 changed files with 30 additions and 12 deletions

View File

@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
import datetime
import tempfile
import shutil
from django.db import models
# Can't import as "forms" due to implementation details in the test suite (the
@@ -41,6 +42,12 @@ True
{'file1': <SimpleUploadedFile: 我隻氣墊船裝滿晒鱔.txt (text/plain)>}
>>> m = FileModel.objects.create(file=f.cleaned_data['file1'])
# It's enough that m gets created without error. Preservation of the exotic name is checked
# in a file_uploads test; it's hard to do that correctly with doctest's unicode issues. So
# we create and then immediately delete m so as to not leave the exotically named file around
# for shutil.rmtree (on Windows) to have trouble with later.
>>> m.delete()
# Boundary conditions on a PostitiveIntegerField #########################
>>> class BoundaryForm(ModelForm):
... class Meta:
@@ -78,4 +85,5 @@ u'instance value'
datetime.date(1969, 4, 4)
>>> instance_form.initial['value']
12
>>> shutil.rmtree(temp_storage_location)
"""}