Opened 14 hours ago

Last modified 10 hours ago

#36680 assigned Bug

Formatters run on `TemplateCommand` make `admin_scripts` tests brittle

Reported by: Natalia Bidart Owned by: Jacob Walls
Component: Core (Management commands) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Some admin_scripts tests, such as those for startproject, assert literal file contents generated from templates. Because TemplateCommand runs formatters before exiting (run_formatters(...)), the output can differ depending on environment details such as temporary directory path length or whether black is installed.

For example, when black reformats long lines during parallel test runs, strings in the generated manage.py file are wrapped in parentheses, causing assertion failures.

Tests should not depend on the exact output of formatters. Mocking or disabling them during test runs would make the suite more stable.

Change History (7)

comment:1 by Natalia Bidart, 14 hours ago

Has patch: set

comment:2 by Jacob Walls, 13 hours ago

Triage Stage: UnreviewedAccepted

comment:3 by Natalia Bidart, 12 hours ago

Owner: changed from Natalia Bidart to Jacob Walls

comment:4 by Natalia Bidart, 12 hours ago

Triage Stage: AcceptedReady for checkin

comment:5 by Natalia Bidart, 11 hours ago

Triage Stage: Ready for checkinAccepted

comment:6 by Natalia Bidart, 11 hours ago

Patch needs improvement: set

There are other tests failures that need to be logged at.

comment:7 by Jacob Walls, 10 hours ago

Patch needs improvement: unset

I expect some more discussion about the merit of the approach, but I pushed some edits that should handle those failures.

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