[Django] #35662: running tests now requires static files to be generated when using ManifestStaticFilesStorage

17 views
Skip to first unread message

Django

unread,
Aug 8, 2024, 6:47:27 AM8/8/24
to django-...@googlegroups.com
#35662: running tests now requires static files to be generated when using
ManifestStaticFilesStorage
-------------------------------------+-------------------------------------
Reporter: Patrick Rauscher | Type: Bug
Status: new | Component:
| Documentation
Version: 5.1 | Severity: Normal
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Hello everyone,

while migrating from django 5.0 to 5.1, I experienced a change in behavior
when running unittests. We are using ManifestStaticFilesStorage, and
during development and unittesting, collectstatic have never been called,
as static files were only required for the final result.

This did not pose a problem in 5.0, but after switching to 5.1, tests
using templates with static-templatetags failed with "Missing staticfiles
manifest entry for 'admin/css/base.css'".

Of course, there are multiple ways to fix this for a given project, such
as
* changing settings.py to use simple StaticFilesStorage during tests (e.g.
detected by environment variable)
* running collectstatic before running tests

But, as the problem is not described in Release Notes or
https://docs.djangoproject.com/en/5.0/topics/testing/overview/, users
might be puzzled first.
Not sure what the best way to deal with this issue would be, but maybe it
could at least be added to documentation?
--
Ticket URL: <https://code.djangoproject.com/ticket/35662>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 8, 2024, 6:49:55 AM8/8/24
to django-...@googlegroups.com
#35662: running tests now requires static files to be generated when using
ManifestStaticFilesStorage
----------------------------------+--------------------------------------
Reporter: Patrick Rauscher | Owner: (none)
Type: Bug | Status: new
Component: Documentation | Version: 5.1
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
----------------------------------+--------------------------------------
Description changed by Patrick Rauscher:

Old description:

> Hello everyone,
>
> while migrating from django 5.0 to 5.1, I experienced a change in
> behavior when running unittests. We are using ManifestStaticFilesStorage,
> and during development and unittesting, collectstatic have never been
> called, as static files were only required for the final result.
>
> This did not pose a problem in 5.0, but after switching to 5.1, tests
> using templates with static-templatetags failed with "Missing staticfiles
> manifest entry for 'admin/css/base.css'".
>
> Of course, there are multiple ways to fix this for a given project, such
> as
> * changing settings.py to use simple StaticFilesStorage during tests
> (e.g. detected by environment variable)
> * running collectstatic before running tests
>
> But, as the problem is not described in Release Notes or
> https://docs.djangoproject.com/en/5.0/topics/testing/overview/, users
> might be puzzled first.
> Not sure what the best way to deal with this issue would be, but maybe it
> could at least be added to documentation?

New description:

Hello everyone,

while migrating from django 5.0.8 to 5.1, I experienced a change in
behavior when running unittests. We are using ManifestStaticFilesStorage,
and during development and unittesting, collectstatic have never been
called, as static files were only required for the final result.

This did not pose a problem in 5.0.8, but after switching to 5.1, tests
using templates with static-templatetags failed with "Missing staticfiles
manifest entry for 'admin/css/base.css'".

Of course, there are multiple ways to fix this for a given project, such
as
* changing settings.py to use simple StaticFilesStorage during tests (e.g.
detected by environment variable)
* running collectstatic before running tests

But, as the problem is not described in Release Notes or
https://docs.djangoproject.com/en/5.0/topics/testing/overview/, users
might be puzzled first.
Not sure what the best way to deal with this issue would be, but maybe it
could at least be added to documentation?

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

Django

unread,
Aug 8, 2024, 8:02:14 AM8/8/24
to django-...@googlegroups.com
#35662: running tests now requires static files to be generated when using
ManifestStaticFilesStorage
-------------------------------------+-------------------------------------
Reporter: Patrick Rauscher | Owner: (none)
Type: Bug | Status: closed
Component: contrib.staticfiles | Version: 5.1
Severity: Normal | Resolution: needsinfo
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 Natalia Bidart):

* component: Documentation => contrib.staticfiles
* resolution: => needsinfo
* status: new => closed

Comment:

Hello Patrick, thank you for your ticket!

Could you please provide a small Django project or a test case to
reproduce? Ideally you could also
[https://docs.djangoproject.com/en/5.1/internals/contributing/triaging-
tickets/#bisecting-a-regression bisect the commit] that introduced this
behavior.

Given the above, I'll close the ticket accordingly, but please re-open
when you can provides the extra details. Thanks again!
--
Ticket URL: <https://code.djangoproject.com/ticket/35662#comment:2>

Django

unread,
Aug 9, 2024, 3:53:27 AM8/9/24
to django-...@googlegroups.com
#35662: running tests now requires static files to be generated when using
ManifestStaticFilesStorage
-------------------------------------+-------------------------------------
Reporter: Patrick Rauscher | Owner: (none)
Type: Bug | Status: closed
Component: contrib.staticfiles | Version: 5.1
Severity: Normal | Resolution: needsinfo
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 Patrick Rauscher):

Hey Natalia,

thank you for your comment - I spend some time debugging the issue and
have to admit the issue is within my test case definition: I used
{{{
@override_settings(STATICFILES_STORAGE="django.contrib.staticfiles.storage.StaticFilesStorage")
class MainTestCase(django.test.TestCase): ...
}}}
as a Main Test-Class and inherited my other TestCases from this
MainTestCase, forgetting about this override in the process.
As STATICFILES_STORAGE got removed in 5.1, this override didn't work any
longer and test cases broke.

As deprecation of STATICFILES_STORAGE is documented, there is no change
needed, this comment should just serve as information for any poor soul
reaching the ticket by google :)

Updating the override to STORAGES=... did obviously help.
--
Ticket URL: <https://code.djangoproject.com/ticket/35662#comment:3>

Django

unread,
Aug 9, 2024, 7:44:30 AM8/9/24
to django-...@googlegroups.com
#35662: running tests now requires static files to be generated when using
ManifestStaticFilesStorage
-------------------------------------+-------------------------------------
Reporter: Patrick Rauscher | Owner: (none)
Type: Bug | Status: closed
Component: contrib.staticfiles | Version: 5.1
Severity: Normal | Resolution: invalid
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 Natalia Bidart):

* resolution: needsinfo => invalid

Comment:

Amazing, thank you Patrick for sharing your conclusions. I'll change the
ticket resolution accordingly then.
--
Ticket URL: <https://code.djangoproject.com/ticket/35662#comment:4>
Reply all
Reply to author
Forward
0 new messages