Opened 14 years ago

Closed 14 years ago

Last modified 6 years ago

#15362 closed (fixed)

The file_uploads tests are failing on Windows

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

Description

The reason is known and commented:

# Cleanup the object with its exotic file name immediately.
# (shutil.rmtree used elsewhere in the tests to clean up the
# upload directory has been seen to choke on unicode
# filenames on Windows.)

http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/file_uploads/views.py?rev=15599#L69

But the current fix (deleting a model instance) does not help.

I'm attaching a patch with a trivial fix.

Before patch:

C:\devel\python\django\tests>runtests.py --settings=test_sqlite file_uploads
Creating test database for alias 'default'...
Creating test database for alias 'other'...
.........EE.
======================================================================
ERROR: test_not_a_directory (regressiontests.file_uploads.tests.DirectoryCreatio
nTests)
The correct IOError is raised when the upload directory name exists but isn't a
directory
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\devel\python\django\tests\regressiontests\file_uploads\tests.py", lin
e 266, in setUp
    shutil.rmtree(UPLOAD_TO)
  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 123] Nßzev souboru, adresß°e nebo jmenovka svazku je nesprß
vn: 'c:\\docume~1\\milosl~1.poj\\locals~1\\temp\\tmpburruj\\test_upload\\test-01
23456789_??_orl\xe9ans.jpg'

======================================================================
ERROR: test_readonly_root (regressiontests.file_uploads.tests.DirectoryCreationT
ests)
Permission errors are not swallowed
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\devel\python\django\tests\regressiontests\file_uploads\tests.py", lin
e 266, in setUp
    shutil.rmtree(UPLOAD_TO)
  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 123] Nßzev souboru, adresß°e nebo jmenovka svazku je nesprß
vn: 'c:\\docume~1\\milosl~1.poj\\locals~1\\temp\\tmpburruj\\test_upload\\test-01
23456789_??_orl\xe9ans.jpg'

----------------------------------------------------------------------
Ran 12 tests in 16.655s

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 file_uploads
Creating test database for alias 'default'...
Creating test database for alias 'other'...
............
----------------------------------------------------------------------
Ran 12 tests in 113.876s

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

Attachments (1)

file_uploads.diff (533 bytes ) - added by Miloslav Pojman 14 years ago.

Download all attachments as: .zip

Change History (6)

by Miloslav Pojman, 14 years ago

Attachment: file_uploads.diff added

comment:1 by Karen Tracey, 14 years ago

milestone: 1.3
Triage Stage: UnreviewedAccepted

Due to the the fix for #6456.

comment:2 by Karen Tracey, 14 years ago

Resolution: fixed
Status: newclosed

In [15602]:

Fixed #15362: Added explicit deletion of file to test, needed now since files are no longer auto-deleted when a referencing object is deleted. Thanks mila.

comment:3 by Karen Tracey, 14 years ago

In [15603]:

[1.2.X] Fixed #15362: Added explicit deletion of file to test, needed now since files are no longer auto-deleted when a referencing object is deleted. Thanks mila.

r15602 from trunk.

comment:4 by Jacob, 13 years ago

milestone: 1.3

Milestone 1.3 deleted

comment:5 by Tim Graham <timograham@…>, 6 years ago

Easy pickings: unset
UI/UX: unset

In a98bcfb:

Refs #15362 -- Removed obsolete workaround in file_uploads test view.

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