#36680: Formatters run on `TemplateCommand` make `admin_scripts` tests brittle
-------------------------------------+-------------------------------------
Reporter: Natalia | Owner: Natalia Bidart
Bidart |
Type: Bug | Status: assigned
Component: Core | Version: dev
(Management commands) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
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.
--
Ticket URL: <
https://code.djangoproject.com/ticket/36680>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.