[Django] #24364: Cannot run `StaticLiveServerTestCase` when `ManifestStaticFilesStorage` used?

61 views
Skip to first unread message

Django

unread,
Feb 18, 2015, 4:45:50 PM2/18/15
to django-...@googlegroups.com
#24364: Cannot run `StaticLiveServerTestCase` when `ManifestStaticFilesStorage`
used?
-----------------------------------+--------------------
Reporter: natevw | Owner: nobody
Type: Uncategorized | Status: new
Component: Testing framework | Version: 1.7
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------
I recently switched a project to the ManifestStaticFilesStorage backend
for the "permacacheable" URLs it gives to resources that may change.
However, this seems to have broken some of my Selenium tests, which use
`StaticLiveServerTestCase` for the browser resources.

Now when I try to run my tests, they fail. I get a bunch of stacktraces
that read

ValueError: The file 'images/favicon.ico' could not be found with
<django.contrib.staticfiles.storage.ManifestStaticFilesStorage object at
0x1037ed290>.

Running `./manage.py collectstatic` before the tests makes the problem go
away, but this is a poor workaround (it leaves stale resources which
become confusing during development). Accessing the site works just fine
via `./manage.py runserver`, but is it expected for tests not to work in
this configuration?

--
Ticket URL: <https://code.djangoproject.com/ticket/24364>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 23, 2015, 1:18:34 PM2/23/15
to django-...@googlegroups.com
#24364: Cannot run `StaticLiveServerTestCase` when `ManifestStaticFilesStorage`
used?
-----------------------------------+--------------------------------------

Reporter: natevw | Owner: nobody
Type: Uncategorized | Status: new
Component: Testing framework | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by natevw):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

Looks like the immediate cause is
[https://docs.djangoproject.com/en/1.7/topics/testing/overview/#other-
test-conditions this]:

> Regardless of the value of the DEBUG setting in your configuration file,
all Django tests run with DEBUG=False.

The `HashedFilesMixin` relies on debug mode to leave URLs alone, so when
that is disabled it expects the manifest file generated by the
`collectstatic` management command.

At this point, the cleanest workaround idea I've found will be to use the
`override_settings` decorator to set it back
([http://stackoverflow.com/a/13596201/179583 as described on here]) on
every method in my Selenium test suite.

--
Ticket URL: <https://code.djangoproject.com/ticket/24364#comment:1>

Django

unread,
Feb 23, 2015, 1:52:08 PM2/23/15
to django-...@googlegroups.com
#24364: Tests fail when `ManifestStaticFilesStorage` used
-----------------------------------+--------------------------------------

Reporter: natevw | Owner: nobody
Type: Uncategorized | Status: new
Component: Testing framework | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------

--
Ticket URL: <https://code.djangoproject.com/ticket/24364#comment:2>

Django

unread,
Feb 23, 2015, 1:55:26 PM2/23/15
to django-...@googlegroups.com
#24364: Tests fail when `ManifestStaticFilesStorage` used
-----------------------------------+--------------------------------------
Reporter: natevw | Owner: nobody
Type: Uncategorized | Status: new
Component: Testing framework | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------

Comment (by natevw):

This was actually breaking all my tests, irregardless of being based on
`StaticLiveServerTestCase` or not. A more robust workaround is to revert
the `STATICFILES_STORAGE` setting during tests. I now put this atop my
tests.py file to work around the situation:

{{{
# WORKAROUND: https://code.djangoproject.com/ticket/24364 by reverting to
default storage
from django.conf import settings, global_settings
settings.STATICFILES_STORAGE = global_settings.STATICFILES_STORAGE
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24364#comment:3>

Django

unread,
Mar 3, 2015, 10:21:11 AM3/3/15
to django-...@googlegroups.com
#24364: Document that ManifestStaticFilesStorage shouldn't be used during testing
--------------------------------------+------------------------------------
Reporter: natevw | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by timgraham):

* type: Uncategorized => Cleanup/optimization
* component: Testing framework => Documentation
* easy: 0 => 1
* stage: Unreviewed => Accepted


Comment:

I asked Jannis about this (author of `ManifestStaticFilesStorage`) and he
said that you shouldn't use `ManifestStaticFilesStorage` during tests, so
I'll triage this as a documentation issue.

--
Ticket URL: <https://code.djangoproject.com/ticket/24364#comment:4>

Django

unread,
Mar 3, 2015, 5:57:30 PM3/3/15
to django-...@googlegroups.com
#24364: Document that ManifestStaticFilesStorage shouldn't be used during testing
--------------------------------------+------------------------------------
Reporter: natevw | Owner: nobody

Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by collinanderson):

* cc: cmawebsite@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/24364#comment:5>

Django

unread,
Mar 12, 2015, 6:21:41 AM3/12/15
to django-...@googlegroups.com
#24364: Document that ManifestStaticFilesStorage shouldn't be used during testing
--------------------------------------+------------------------------------
Reporter: natevw | Owner: aethemba
Type: Cleanup/optimization | Status: assigned

Component: Documentation | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by aethemba):

* owner: nobody => aethemba
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/24364#comment:6>

Django

unread,
Mar 12, 2015, 7:36:39 AM3/12/15
to django-...@googlegroups.com
#24364: Document that ManifestStaticFilesStorage shouldn't be used during testing
--------------------------------------+------------------------------------
Reporter: natevw | Owner: aethemba
Type: Cleanup/optimization | Status: assigned
Component: Documentation | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by aethemba):

* cc: aethemba (added)
* has_patch: 0 => 1


Comment:

This is my first commit to Django so please bear with me.

I wrote a simple piece of documentation for this issue. I'm attaching the
diff file to this ticket.

Furthermore, I've sent a pull request to Django's stable/1.7.x branch.

I'm eager to hear if I've done all steps correctly.

--
Ticket URL: <https://code.djangoproject.com/ticket/24364#comment:7>

Django

unread,
Mar 12, 2015, 7:37:02 AM3/12/15
to django-...@googlegroups.com
#24364: Document that ManifestStaticFilesStorage shouldn't be used during testing
--------------------------------------+------------------------------------
Reporter: natevw | Owner: aethemba
Type: Cleanup/optimization | Status: assigned
Component: Documentation | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by aethemba):

* Attachment "24364.diff" added.

Diff file for ticket 24364

Django

unread,
Mar 12, 2015, 9:17:19 AM3/12/15
to django-...@googlegroups.com
#24364: Document that ManifestStaticFilesStorage shouldn't be used during testing
--------------------------------------+------------------------------------
Reporter: natevw | Owner: aethemba
Type: Cleanup/optimization | Status: assigned
Component: Documentation | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by aethemba):

* Attachment "24364_revised.diff" added.

Diff for ticket #24364

Django

unread,
Mar 12, 2015, 9:23:24 AM3/12/15
to django-...@googlegroups.com
#24364: Document that ManifestStaticFilesStorage shouldn't be used during testing
--------------------------------------+------------------------------------
Reporter: natevw | Owner: aethemba
Type: Cleanup/optimization | Status: closed
Component: Documentation | Version: 1.7
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"b4d8b16e5109170614ba505e36f60c2ad64dafc2" b4d8b16]:
{{{
#!CommitTicketReference repository=""
revision="b4d8b16e5109170614ba505e36f60c2ad64dafc2"
Fixed #24364 -- Doc'ed that ManifestStaticFileStorage shouldn't be used
during testing.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24364#comment:8>

Django

unread,
Mar 12, 2015, 9:24:10 AM3/12/15
to django-...@googlegroups.com
#24364: Document that ManifestStaticFilesStorage shouldn't be used during testing
--------------------------------------+------------------------------------
Reporter: natevw | Owner: aethemba
Type: Cleanup/optimization | Status: closed
Component: Documentation | Version: 1.7
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"fee18ce415cd817c20f64009600b0c7158353974" fee18ce]:
{{{
#!CommitTicketReference repository=""
revision="fee18ce415cd817c20f64009600b0c7158353974"
[1.8.x] Fixed #24364 -- Doc'ed that ManifestStaticFileStorage shouldn't be
used during testing.

Backport of b4d8b16e5109170614ba505e36f60c2ad64dafc2 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24364#comment:9>

Django

unread,
Mar 12, 2015, 9:24:13 AM3/12/15
to django-...@googlegroups.com
#24364: Document that ManifestStaticFilesStorage shouldn't be used during testing
--------------------------------------+------------------------------------
Reporter: natevw | Owner: aethemba
Type: Cleanup/optimization | Status: closed
Component: Documentation | Version: 1.7
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"8084a68f7844ee61bcc5798c7557e2c3b4770b8a" 8084a68]:
{{{
#!CommitTicketReference repository=""
revision="8084a68f7844ee61bcc5798c7557e2c3b4770b8a"
[1.7.x] Fixed #24364 -- Doc'ed that ManifestStaticFileStorage shouldn't be
used during testing.

Backport of b4d8b16e5109170614ba505e36f60c2ad64dafc2 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24364#comment:10>

Reply all
Reply to author
Forward
0 new messages