Opened 17 years ago

Closed 17 years ago

#6825 closed (fixed)

Failed tests when runtests.py is run on Windows

Reported by: Jason Erickson Owned by: Jason Erickson
Component: Testing framework Version: dev
Severity: Keywords: windows, doctest, test
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

When runing Django's runtests.py on Windows, modeltests/models_forms/models.py fails:

======================================================================
FAIL: Doctest: modeltests.model_forms.models.__test__.API_TESTS
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\prj\djangodev\django\test\_doctest.py", line 2180, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for modeltests.model_forms.models.__test__.API_TESTS
  File "C:\prj\djangodev\tests\modeltests\model_forms\models.py", line unknown line number, in API_TESTS

----------------------------------------------------------------------
File "C:\prj\djangodev\tests\modeltests\model_forms\models.py", line ?, in modeltests.model_forms.models.__test__.API_TESTS
Failed example:
    instance.file
Expected:
    u'.../test1.txt'
Got:
    u'c:\\users\\owner\\appdata\\local\\temp\\test1.txt'
----------------------------------------------------------------------
File "C:\prj\djangodev\tests\modeltests\model_forms\models.py", line ?, in modeltests.model_forms.models.__test__.API_TESTS
Failed example:
    f.cleaned_data['file']
Expected:
    u'.../test1.txt'
Got:
    u'c:\\users\\owner\\appdata\\local\\temp\\test1.txt'
----------------------------------------------------------------------
File "C:\prj\djangodev\tests\modeltests\model_forms\models.py", line ?, in modeltests.model_forms.models.__test__.API_TESTS
Failed example:
    instance.file
Expected:
    u'.../test1.txt'
Got:
    u'c:\\users\\owner\\appdata\\local\\temp\\test1.txt'
----------------------------------------------------------------------
File "C:\prj\djangodev\tests\modeltests\model_forms\models.py", line ?, in modeltests.model_forms.models.__test__.API_TESTS
Failed example:
    instance.file
Expected:
    u'.../test2.txt'
Got:
    u'c:\\users\\owner\\appdata\\local\\temp\\test2.txt'
----------------------------------------------------------------------
File "C:\prj\djangodev\tests\modeltests\model_forms\models.py", line ?, in modeltests.model_forms.models.__test__.API_TESTS
Failed example:
    instance.file
Expected:
    u'.../test3.txt'
Got:
    u'c:\\users\\owner\\appdata\\local\\temp\\test3.txt'
----------------------------------------------------------------------
File "C:\prj\djangodev\tests\modeltests\model_forms\models.py", line ?, in modeltests.model_forms.models.__test__.API_TESTS
Failed example:
    instance.image
Expected:
    u'.../test.png'
Got:
    u'c:\\users\\owner\\appdata\\local\\temp\\test.png'
----------------------------------------------------------------------
File "C:\prj\djangodev\tests\modeltests\model_forms\models.py", line ?, in modeltests.model_forms.models.__test__.API_TESTS
Failed example:
    f.cleaned_data['image']
Expected:
    u'.../test.png'
Got:
    u'c:\\users\\owner\\appdata\\local\\temp\\test.png'
----------------------------------------------------------------------
File "C:\prj\djangodev\tests\modeltests\model_forms\models.py", line ?, in modeltests.model_forms.models.__test__.API_TESTS
Failed example:
    instance.image
Expected:
    u'.../test.png'
Got:
    u'c:\\users\\owner\\appdata\\local\\temp\\test.png'
----------------------------------------------------------------------
File "C:\prj\djangodev\tests\modeltests\model_forms\models.py", line ?, in modeltests.model_forms.models.__test__.API_TESTS
Failed example:
    instance.image
Expected:
    u'.../test2.png'
Got:
    u'c:\\users\\owner\\appdata\\local\\temp\\test2.png'
----------------------------------------------------------------------
File "C:\prj\djangodev\tests\modeltests\model_forms\models.py", line ?, in modeltests.model_forms.models.__test__.API_TESTS
Failed example:
    instance.image
Expected:
    u'.../test3.png'
Got:
    u'c:\\users\\owner\\appdata\\local\\temp\\test3.png'


----------------------------------------------------------------------

These tests fail because of comparing a forward slash before the file name with the doctest in modeltests/model/forms/models.py, where windows uses the backslash as a separator for directories and files. The attached patch changes the doctest to not compare the slash at the beginning of the filename to allow it to pass on windows.

Attachments (1)

model-windows-fix.diff (1.9 KB ) - added by Jason Erickson 17 years ago.
Patch to moteltests/models_forms/models.py that removes the / when testing the filenames.

Download all attachments as: .zip

Change History (3)

by Jason Erickson, 17 years ago

Attachment: model-windows-fix.diff added

Patch to moteltests/models_forms/models.py that removes the / when testing the filenames.

comment:1 by Jason Erickson, 17 years ago

Owner: changed from nobody to Jason Erickson
Triage Stage: UnreviewedReady for checkin

comment:2 by Malcolm Tredinnick, 17 years ago

Resolution: fixed
Status: newclosed

(In [7335]) Fixed #6825 -- Fixed the model_forms tests to also work on Windows by making
the filename detection a lot looser. Thanks, jerickso.

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