Opened 5 months ago

Closed 4 months ago

Last modified 4 months ago

#29464 closed Cleanup/optimization (fixed)

Move collectstatic post processing messages to verbosity 2

Reported by: David Szotten Owned by: Arthur Silva
Component: contrib.staticfiles Version: 2.1
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

collectstatic logs "Post-processed foo as bar with level 1, but this is a lot of output and may be more suitable to
level 2, like "Copying foo"

https://github.com/django/django/blob/e1ebd22558342bb0088a3da3571863a20413fa2a/django/contrib/staticfiles/management/commands/collectstatic.py#L136

Change History (11)

comment:1 Changed 5 months ago by Tim Graham

Component: Core (Management commands)contrib.staticfiles
Summary: collectstatic verbosityMove collectstatic post processing messages to verbosity 2
Type: UncategorizedCleanup/optimization
Version: 2.02.1

(Follow up to #28973.)

comment:2 Changed 5 months ago by Tim Graham

Easy pickings: set

comment:3 Changed 4 months ago by Tim Graham

Triage Stage: UnreviewedAccepted

comment:4 Changed 4 months ago by Arthur Silva

Owner: changed from nobody to Arthur Silva
Status: newassigned

comment:5 Changed 4 months ago by Arthur Silva

Hi @Tim Graham,

How can I test post_process inside TestCollectionVerbosity class located in django/tests/staticfiles_tests/test_management.py ?

I've tried:

    def test_verbosity_1(self):
        stdout = StringIO()
        self.run_collectstatic(verbosity=1, stdout=stdout, post_process=True)
        output = stdout.getvalue()
        self.assertIn(self.staticfiles_copied_msg, output)
        self.assertNotIn(self.copying_msg, output)
        self.assertNotIn(self.post_process_msg, output)

where self.post_process_msg is equal to 'Post-process'.

However I can't make post_process be triggered. So, the test passes even message post_process_msg is printed with verbose=1.

I may be missing some 'storage' initialization.

Can you give a hint, please?

Thanks.

comment:6 Changed 4 months ago by David Szotten

you probably need to enable a storage backend that uses post processing, e.g. using

    @override_settings(STATICFILES_STORAGE='django.contrib.staticfiles.storage.CachedStaticFilesStorage')
    def test_foo(self):

see https://github.com/django/django/blob/7a266e25be1b641111ab5889f9808ff6d258d27f/django/contrib/staticfiles/management/commands/collectstatic.py#L125

comment:7 Changed 4 months ago by Arthur Silva

Resolution: fixed
Status: assignedclosed

Thanks David.

I've submitted a PR.

comment:8 Changed 4 months ago by Tim Graham

Has patch: set
Resolution: fixed
Status: closednew

The ticket is closed when the PR is merged. You should instead check "Has patch" when adding a pull request.

comment:9 Changed 4 months ago by Arthur Silva

My bad.

Thanks for changing it to "Has patch".

comment:10 Changed 4 months ago by Tim Graham <timograham@…>

Resolution: fixed
Status: newclosed

In bc143555:

Fixed #29464 -- Silenced post-process messages in collectstatic's default verbosity.

comment:11 Changed 4 months ago by Tim Graham <timograham@…>

In 91a02dce:

[2.1.x] Fixed #29464 -- Silenced post-process messages in collectstatic's default verbosity.

Backport of bc1435551c0cfaf4a22aff8216990b909005dba9 from master

Note: See TracTickets for help on using tickets.
Back to Top