#11032: Failed regressiontest on Windows for ImageField
-----------------------------------------------+----------------------------
 Reporter:  joeri                              |       Owner:  nobody    
   Status:  new                                |   Milestone:            
Component:  File uploads/storage               |     Version:  SVN       
 Keywords:  regressiontest imagefield windows  |       Stage:  Unreviewed
Has_patch:  0                                  |  
-----------------------------------------------+----------------------------
 On Windows (Vista32), the file_storage test fails if PIL is installed (if
 PIL is not installed, this test is not executed):

 {{{
 ======================================================================
 FAIL: Doctest: regressiontests.file_storage.models.__test__.API_TESTS
 ----------------------------------------------------------------------
 Traceback (most recent call last):
   File "C:\edc\django-trunk\django\test\_doctest.py", line 2180, in
 runTest
 AssertionError: Failed doctest test for
 regressiontests.file_storage.models.__test__.API_TESTS
   File "C:\edc\django_src\tests\regressiontests\file_storage\models.py",
 line unknown line number, in API_TESTS

 ----------------------------------------------------------------------
 File "C:\edc\django_src\tests\regressiontests\file_storage\models.py",
 line ?, in regressiontests.file_storage.models.__test__.API_TESTS
 Failed example:
     shutil.rmtree(temp_storage_dir)
 Exception raised:
     Traceback (most recent call last):
       File "C:\edc\django-trunk\django\test\_doctest.py", line 1267, in
 __run
       File "<doctest
 regressiontests.file_storage.models.__test__.API_TESTS[26]>", line 1, in
 <module>
         shutil.rmtree(temp_storage_dir)
       File "C:\Program Files\Python 2.5\Lib\shutil.py", line 169, in
 rmtree
         rmtree(fullname, ignore_errors, onerror)
       File "C:\Program Files\Python 2.5\Lib\shutil.py", line 174, in
 rmtree
         onerror(os.remove, fullname, sys.exc_info())
       File "C:\Program Files\Python 2.5\Lib\shutil.py", line 172, in
 rmtree
         os.remove(fullname)
     WindowsError: [Error 32] The process cannot access the file because it
 is being used by another
     process:
 'c:\\users\\joeri\\appdata\\local\\temp\\tmp34vz8s\\tests\\mug'


 ----------------------------------------------------------------------
 Ran 4 tests in 1.116s

 FAILED (failures=1)
 }}}

 When cleaning up at the end of the test
 (tests/regressiontests/file_storage/models.py), {{{shutil.rmtree}}} has
 problems with {{{p.mugshot._file}}} still being opened by a process. The
 quickfix is to add {{{>>> p.mugshot.close()}}} just _before_ the last line
 of the test: {{{>>> shutil.rmtree(temp_storage_dir)}}}.

 It's a perk of {{{shutil}}} on Windows (other platforms seem to don't care
 and just remove the file anyway) that exposes this but the actual cause
 might be deeper. The file (p.mugshot._file) is left open (or even reopened
 despite the dimension_cache...) by calling {{{p.mugshot.width}}} and/or
 {{{p.mugshot.height}}}. Removing the lines below from the test also
 "removes" the problem:

 {{{
 >>> p.mugshot.width
 16
 >>> p.mugshot.height
 16
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/11032>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to