|
|
@@ -1,11 +1,8 @@ |
|
|
# -*- coding: utf-8 -*-
|
|
|
"""
|
|
|
A series of tests to establish that the command-line management tools work as
|
|
|
advertised - especially with regards to the handling of the
|
|
|
DJANGO_SETTINGS_MODULE and default settings.py files.
|
|
|
"""
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
import codecs
|
|
|
import os
|
|
|
import re
|
|
|
@@ -30,7 +27,7 @@ |
|
|
)
|
|
|
from django.utils._os import npath, upath
|
|
|
from django.utils.encoding import force_text
|
|
|
from django.utils.six import PY2, PY3, StringIO
|
|
|
from django.utils.six import PY2, StringIO
|
|
|
|
|
|
custom_templates_dir = os.path.join(os.path.dirname(upath(__file__)), 'custom_templates')
|
|
|
|
|
|
@@ -67,7 +64,6 @@ def write_settings(self, filename, apps=None, is_dir=False, sdict=None, extra=No |
|
|
settings_file_path = os.path.join(self.test_dir, filename)
|
|
|
|
|
|
with open(settings_file_path, 'w') as settings_file:
|
|
|
settings_file.write('# -*- coding: utf-8 -*\n')
|
|
|
settings_file.write('# Settings file automatically generated by admin_scripts test case\n')
|
|
|
if extra:
|
|
|
settings_file.write("%s\n" % extra)
|
|
|
@@ -614,26 +610,10 @@ def test_setup_environ(self): |
|
|
self.addCleanup(shutil.rmtree, app_path)
|
|
|
self.assertNoOutput(err)
|
|
|
self.assertTrue(os.path.exists(app_path))
|
|
|
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:
|
|
|
content = f.read()
|
|
|
self.assertIn("class SettingsTestConfig(AppConfig)", content)
|
|
|
self.assertIn("name = 'settings_test'", content)
|
|
|
if not PY3:
|
|
|
self.assertIn(unicode_literals_import, content)
|
|
|
if not PY3:
|
|
|
with open(os.path.join(app_path, 'models.py'), 'r') as fp:
|
|
|
content = fp.read()
|
|
|
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):
|
|
|
"directory: startapp creates the correct directory with a custom template"
|
|
|
|
Stale docstring?