Django test suite doesn't pass on Windows when checked out of git
|Reported by:||dlanger||Owned by:||nobody|
|Cc:||Jannis Leidel||Triage Stage:||Unreviewed|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
There are several tests in the Django test suite that are line-ending dependent - for example,
regressiontests.admin_views.tests.AdminSearchTest, which asserts the presence of
\n1 user\n (as well as a few others that have
\n in their assertions). These test pass in environments that use LF as their default line ending.
git's default behaviour is to change LF line endings to CRLF when a file is loaded from the object database, and convert them back to LF when they're committed. This causes those tests to fail, since
\n1 user\n isn't there -
\r\n1 user\r\n is.
This can be fixed by adding a
.gitattributes file to the root of the Django repo, which tells git clients how to handle those files. The one attached is minimal - it says to treat all HTML files as text, and to keep the line endings as LF for those files. See here for a post on cross-platform line endings and git, and the format of the
To reproduce, check out the root Django repo into a Windows environment using standard Windows git (eg. from GitHub) - downloading and extracting a tarball won't do the bad line-ending conversion - and run
python runtests.py --settings=test_sqlite admin_views.
Tested on Windows7 x64, git 1.7.11, and HEAD of