Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#15364 closed (fixed)

TestCase files.FileTests failing on Windows

Reported by: Miloslav Pojman Owned by: nobody
Component: File uploads/storage Version: dev
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The reason is that Windows can not delete a file which is open.

I'm attaching a patch which fixes it by closing the opened files.

Before patch:

C:\devel\python\django\tests>runtests.py --settings=test_sqlite files.FileTests
Creating test database for alias 'default'...
Creating test database for alias 'other'...
EE
======================================================================
ERROR: test_files (modeltests.files.tests.FileTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\devel\python\django\tests\modeltests\files\tests.py", line 100, in te
st_files
    obj3.default.delete()
  File "C:\devel\python\django\django\db\models\fields\files.py", line 111, in d
elete
    self.storage.delete(self.name)
  File "C:\devel\python\django\django\core\files\storage.py", line 215, in delet
e
    os.remove(name)
WindowsError: [Error 32] Proces nemß p°Ýstup k souboru, neboŁ jej prßvý vyu×Ývß
jinř proces: u'c:\\docume~1\\milosl~1.poj\\locals~1\\temp\\tmpahds2v\\tests\\def
ault.txt'

======================================================================
ERROR: test_files (modeltests.files.tests.FileTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\devel\python\django\tests\modeltests\files\tests.py", line 16, in tea
rDown
    shutil.rmtree(temp_storage_location)
  File "C:\Program Files\python25\lib\shutil.py", line 169, in rmtree
    rmtree(fullname, ignore_errors, onerror)
  File "C:\Program Files\python25\lib\shutil.py", line 174, in rmtree
    onerror(os.remove, fullname, sys.exc_info())
  File "C:\Program Files\python25\lib\shutil.py", line 172, in rmtree
    os.remove(fullname)
WindowsError: [Error 32] Proces nemß p°Ýstup k souboru, neboŁ jej prßvý vyu×Ývß
jinř proces: 'c:\\docume~1\\milosl~1.poj\\locals~1\\temp\\tmpahds2v\\tests\\defa
ult.txt'

----------------------------------------------------------------------
Ran 1 test in 0.062s

FAILED (errors=2)
Destroying test database for alias 'default'...
Destroying test database for alias 'other'...

After patch:

C:\devel\python\django\tests>runtests.py --settings=test_sqlite files.FileTests
Creating test database for alias 'default'...
Creating test database for alias 'other'...
.
----------------------------------------------------------------------
Ran 1 test in 0.046s

OK
Destroying test database for alias 'default'...
Destroying test database for alias 'other'...

Attachments (1)

FileTests.diff (1.5 KB ) - added by Miloslav Pojman 14 years ago.

Download all attachments as: .zip

Change History (4)

by Miloslav Pojman, 14 years ago

Attachment: FileTests.diff added

comment:1 by Russell Keith-Magee, 14 years ago

Triage Stage: UnreviewedReady for checkin

comment:2 by Russell Keith-Magee, 14 years ago

Resolution: fixed
Status: newclosed

In [15604]:

Fixed #15364 -- Ensure files are closed correctly during file tests. Thanks to Mila for the report and patch.

comment:3 by Russell Keith-Magee, 14 years ago

In [15608]:

[1.2.X] Fixed #15364 -- Ensure files are closed correctly during file tests. Thanks to Mila for the report and patch.

Backport of r15604 from trunk.

Note: See TracTickets for help on using tickets.
Back to Top