mirror of
https://github.com/django/django.git
synced 2024-12-22 09:05:43 +00:00
Fixed #34085 -- Made management commands don't use black for non-Python files.
Bug in d113b5a837
.
Co-authored-by: programmylife <acmshar@gmail.com>
Co-authored-by: Carlton Gibson <carlton.gibson@noumenal.es>
This commit is contained in:
parent
d62563cbb1
commit
5c2c7277d4
@ -84,7 +84,6 @@ class TemplateCommand(BaseCommand):
|
||||
)
|
||||
|
||||
def handle(self, app_or_project, name, target=None, **options):
|
||||
self.written_files = []
|
||||
self.app_or_project = app_or_project
|
||||
self.a_or_an = "an" if app_or_project == "app" else "a"
|
||||
self.paths_to_remove = []
|
||||
@ -209,7 +208,6 @@ class TemplateCommand(BaseCommand):
|
||||
else:
|
||||
shutil.copyfile(old_path, new_path)
|
||||
|
||||
self.written_files.append(new_path)
|
||||
if self.verbosity >= 2:
|
||||
self.stdout.write("Creating %s" % new_path)
|
||||
try:
|
||||
@ -232,7 +230,7 @@ class TemplateCommand(BaseCommand):
|
||||
else:
|
||||
shutil.rmtree(path_to_remove)
|
||||
|
||||
run_formatters(self.written_files, **formatter_paths)
|
||||
run_formatters([top_dir], **formatter_paths)
|
||||
|
||||
def handle_template(self, template, subdir):
|
||||
"""
|
||||
|
@ -9,4 +9,6 @@ Django 4.1.3 fixes several bugs in 4.1.2.
|
||||
Bugfixes
|
||||
========
|
||||
|
||||
* ...
|
||||
* Fixed a bug in Django 4.1 that caused non-Python files created by
|
||||
``startproject`` and ``startapp`` management commands from custom templates
|
||||
to be incorrectly formatted using the ``black`` command (:ticket:`34085`).
|
||||
|
@ -0,0 +1,5 @@
|
||||
# Should not be processed by `black`.
|
||||
Django<4.2
|
||||
environs[django]
|
||||
psycopg2-binary
|
||||
django-extensions
|
@ -2483,6 +2483,23 @@ class StartProject(LiveServerTestCase, AdminScriptTestCase):
|
||||
self.assertTrue(os.path.isdir(testproject_dir))
|
||||
self.assertTrue(os.path.exists(os.path.join(testproject_dir, "additional_dir")))
|
||||
|
||||
def test_custom_project_template_non_python_files_not_formatted(self):
|
||||
template_path = os.path.join(custom_templates_dir, "project_template")
|
||||
args = ["startproject", "--template", template_path, "customtestproject"]
|
||||
testproject_dir = os.path.join(self.test_dir, "customtestproject")
|
||||
|
||||
_, err = self.run_django_admin(args)
|
||||
self.assertNoOutput(err)
|
||||
with open(
|
||||
os.path.join(template_path, "additional_dir", "requirements.in")
|
||||
) as f:
|
||||
expected = f.read()
|
||||
with open(
|
||||
os.path.join(testproject_dir, "additional_dir", "requirements.in")
|
||||
) as f:
|
||||
result = f.read()
|
||||
self.assertEqual(expected, result)
|
||||
|
||||
def test_template_dir_with_trailing_slash(self):
|
||||
"Ticket 17475: Template dir passed has a trailing path separator"
|
||||
template_path = os.path.join(custom_templates_dir, "project_template" + os.sep)
|
||||
|
Loading…
Reference in New Issue
Block a user