﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
15364	TestCase files.FileTests failing on Windows	Miloslav Pojman	nobody	"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'...
}}}"		closed	File uploads/storage	dev		fixed			Ready for checkin	1	0	0	0	0	0
