Code

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#15362 closed (fixed)

The file_uploads tests are failing on Windows

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

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 mila 3 years ago.

Download all attachments as: .zip

Change History (5)

Changed 3 years ago by mila

comment:1 Changed 3 years ago by kmtracey

  • milestone set to 1.3
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Due to the the fix for #6456.

comment:2 Changed 3 years ago by kmtracey

  • Resolution set to fixed
  • Status changed from new to closed

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 Changed 3 years ago by kmtracey

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 Changed 3 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.