diff options
| author | Karen Tracey <kmtracey@gmail.com> | 2009-04-05 20:59:20 +0000 |
|---|---|---|
| committer | Karen Tracey <kmtracey@gmail.com> | 2009-04-05 20:59:20 +0000 |
| commit | d0c897d6605a95c3e7826ee7f01ef20979977ebb (patch) | |
| tree | 52bcfb8f95b5b32178005ff810c5a322b619e83c /tests/regressiontests/forms | |
| parent | 6d5492630d22c839142a38846aa8b7e2340427cb (diff) | |
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
Diffstat (limited to 'tests/regressiontests/forms')
| -rw-r--r-- | tests/regressiontests/forms/models.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/regressiontests/forms/models.py b/tests/regressiontests/forms/models.py index 86bfb4b920..157595388e 100644 --- a/tests/regressiontests/forms/models.py +++ b/tests/regressiontests/forms/models.py @@ -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) """} |
