Opened 7 years ago

Closed 7 years ago

#6825 closed (fixed)

Failed tests when runtests.py is run on Windows

Reported by: jerickso Owned by: jerickso
Component: Testing framework Version: master
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: UI/UX:

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 jerickso 7 years ago.
Patch to moteltests/models_forms/models.py that removes the / when testing the filenames.

Download all attachments as: .zip

Change History (3)

Changed 7 years ago by jerickso

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

comment:1 Changed 7 years ago by jerickso

  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to jerickso
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Ready for checkin

comment:2 Changed 7 years ago by mtredinnick

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

(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