mirror of
https://github.com/django/django.git
synced 2025-03-12 10:22:37 +00:00
Fixed #27171 -- Added unicode_literals and coding preamble to all files in startapp template on Python 2.
This commit is contained in:
parent
277fe2e8f2
commit
9a2a52558e
@ -1,3 +1,3 @@
|
|||||||
from django.contrib import admin
|
{{ unicode_literals }}from django.contrib import admin
|
||||||
|
|
||||||
# Register your models here.
|
# Register your models here.
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
from django.test import TestCase
|
{{ unicode_literals }}from django.test import TestCase
|
||||||
|
|
||||||
# Create your tests here.
|
# Create your tests here.
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
from django.shortcuts import render
|
{{ unicode_literals }}from django.shortcuts import render
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
@ -114,7 +114,8 @@ class TemplateCommand(BaseCommand):
|
|||||||
camel_case_name: camel_case_value,
|
camel_case_name: camel_case_value,
|
||||||
'docs_version': get_docs_version(),
|
'docs_version': get_docs_version(),
|
||||||
'django_version': django.__version__,
|
'django_version': django.__version__,
|
||||||
'unicode_literals': '' if six.PY3 else 'from __future__ import unicode_literals\n\n',
|
'unicode_literals': '' if six.PY3 else '# -*- coding: utf-8 -*-\n'
|
||||||
|
'from __future__ import unicode_literals\n\n',
|
||||||
}), autoescape=False)
|
}), autoescape=False)
|
||||||
|
|
||||||
# Setup a stub settings environment for template rendering
|
# Setup a stub settings environment for template rendering
|
||||||
|
@ -613,7 +613,7 @@ class DjangoAdminSettingsDirectory(AdminScriptTestCase):
|
|||||||
self.addCleanup(shutil.rmtree, app_path)
|
self.addCleanup(shutil.rmtree, app_path)
|
||||||
self.assertNoOutput(err)
|
self.assertNoOutput(err)
|
||||||
self.assertTrue(os.path.exists(app_path))
|
self.assertTrue(os.path.exists(app_path))
|
||||||
unicode_literals_import = "from __future__ import unicode_literals\n"
|
unicode_literals_import = "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\n"
|
||||||
with open(os.path.join(app_path, 'apps.py'), 'r') as f:
|
with open(os.path.join(app_path, 'apps.py'), 'r') as f:
|
||||||
content = f.read()
|
content = f.read()
|
||||||
self.assertIn("class SettingsTestConfig(AppConfig)", content)
|
self.assertIn("class SettingsTestConfig(AppConfig)", content)
|
||||||
@ -624,6 +624,15 @@ class DjangoAdminSettingsDirectory(AdminScriptTestCase):
|
|||||||
with open(os.path.join(app_path, 'models.py'), 'r') as fp:
|
with open(os.path.join(app_path, 'models.py'), 'r') as fp:
|
||||||
content = fp.read()
|
content = fp.read()
|
||||||
self.assertIn(unicode_literals_import, content)
|
self.assertIn(unicode_literals_import, content)
|
||||||
|
with open(os.path.join(app_path, 'views.py'), 'r') as fp:
|
||||||
|
content = fp.read()
|
||||||
|
self.assertIn(unicode_literals_import, content)
|
||||||
|
with open(os.path.join(app_path, 'admin.py'), 'r') as fp:
|
||||||
|
content = fp.read()
|
||||||
|
self.assertIn(unicode_literals_import, content)
|
||||||
|
with open(os.path.join(app_path, 'tests.py'), 'r') as fp:
|
||||||
|
content = fp.read()
|
||||||
|
self.assertIn(unicode_literals_import, content)
|
||||||
|
|
||||||
def test_setup_environ_custom_template(self):
|
def test_setup_environ_custom_template(self):
|
||||||
"directory: startapp creates the correct directory with a custom template"
|
"directory: startapp creates the correct directory with a custom template"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user