mirror of
https://github.com/django/django.git
synced 2025-07-30 08:35:23 +00:00
Fixed #17920 -- Actually pass the full path of a newly created project or app in the template context as mentioned in the startproject docs. Many thanks to Preston Holmes for the initial patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17773 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
1101739668
commit
4219e2b7f8
4 changed files with 41 additions and 4 deletions
|
@ -1534,3 +1534,32 @@ class StartProject(LiveServerTestCase, AdminScriptTestCase):
|
|||
with open(os.path.join(base_path, f)) as fh:
|
||||
self.assertEqual(fh.read(),
|
||||
'# some file for customtestproject test project')
|
||||
|
||||
def test_custom_project_template_context_variables(self):
|
||||
"Make sure template context variables are rendered with proper values"
|
||||
template_path = os.path.join(test_dir, 'admin_scripts', 'custom_templates', 'project_template')
|
||||
args = ['startproject', '--template', template_path, 'another_project', 'project_dir']
|
||||
testproject_dir = os.path.join(test_dir, 'project_dir')
|
||||
os.mkdir(testproject_dir)
|
||||
out, err = self.run_django_admin(args)
|
||||
self.addCleanup(shutil.rmtree, testproject_dir)
|
||||
self.assertNoOutput(err)
|
||||
test_manage_py = os.path.join(testproject_dir, 'manage.py')
|
||||
with open(test_manage_py, 'r') as fp:
|
||||
content = fp.read()
|
||||
self.assertIn("project_name = 'another_project'", content)
|
||||
self.assertIn("project_directory = '%s'" % testproject_dir, content)
|
||||
|
||||
def test_custom_project_destination_missing(self):
|
||||
"""
|
||||
Make sure an exception is raised when the provided
|
||||
destination directory doesn't exist
|
||||
"""
|
||||
template_path = os.path.join(test_dir, 'admin_scripts', 'custom_templates', 'project_template')
|
||||
args = ['startproject', '--template', template_path, 'yet_another_project', 'project_dir2']
|
||||
testproject_dir = os.path.join(test_dir, 'project_dir2')
|
||||
out, err = self.run_django_admin(args)
|
||||
self.assertNoOutput(out)
|
||||
self.assertOutput(err, "Destination directory '%s' does not exist, please create it first." % testproject_dir)
|
||||
self.assertFalse(os.path.exists(testproject_dir))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue