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.