﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
18754	staticfiles test failure under Windows	Karen Tracey	Karen Tracey	"Recording this in a ticket to explain the code change.

{{{
C:\Users\kmtracey\django\git-django\tests>runtests.py --settings=test_sqlite staticfiles_tests.TestCollectionCachedStorage.test_template_tag_return staticfiles_tests.TestCollectionSimpleCachedStorage.test_template_tag_return
Creating test database for alias 'default'...
Creating test database for alias 'other'...
.F
======================================================================
FAIL: test_template_tag_return (regressiontests.staticfiles_tests.tests.TestCollectionSimpleCachedStorage)
----------------------------------------------------------------------
Traceback (most recent call last):
  File ""C:\Users\kmtracey\django\git-django\tests\regressiontests\staticfiles_tests\tests.py"", line 560, in test_template_tag_return
    ""/static/test/file.deploy12345.txt"")
  File ""C:\Users\kmtracey\django\git-django\tests\regressiontests\staticfiles_tests\tests.py"", line 101, in assertStaticRenders
    self.assertEqual(self.render_template(template, **kwargs), result)
AssertionError: u'/static/test/file.dad0999e4f8f.txt' != u'/static/test/file.deploy12345.txt'
- /static/test/file.dad0999e4f8f.txt
?                    ------  ^^^
+ /static/test/file.deploy12345.txt
?                     +++++++ ^


----------------------------------------------------------------------
Ran 2 tests in 1.036s

FAILED (failures=1)
Destroying test database for alias 'default'...
Destroying test database for alias 'other'...
}}}

Both tests test the static rendering of static file ""test/file.txt""

The 2nd test is finding something put in the cache by the first test.

During test setUp, where collectstatic is being called, !CachedFilesMixin post_process is setting up the cache keys for found files by:

{{{
#!python
# and then set the cache accordingly
hashed_paths[self.cache_key(name)] = hashed_name
}}}

here name has backslashes on Windows. Later during the first test run the name looked for has forward slashes, the cache key generated is different than what was put in the cache by setUp, cache misses, and a value is set in the cache for the key value generated with the forward slash version of the name. The cache is not cleared between tests and the 2nd call to setUp again sets up the cache using the names with backslashes, but then when the 2nd test looks up the name with forward slashes it finds the value previously set by the 1st test.

Fix is to replace backslashes with forward slashes in the name used for key generation in post_process. I think. If not someone with a better grasp of this code feel free to step in with the real fix."	Bug	closed	contrib.staticfiles	1.4	Normal	fixed			Unreviewed	0	0	0	0	0	0
