diff options
| author | Andrew Godwin <andrew@aeracode.org> | 2012-07-26 18:58:10 +0100 |
|---|---|---|
| committer | Andrew Godwin <andrew@aeracode.org> | 2012-07-26 18:58:10 +0100 |
| commit | 4a2e80fff44d0eb1856b593ac5f31ab1492b3e45 (patch) | |
| tree | 9bc87a682dc488e6555792c1d4bb53f5f3cdc880 /tests/regressiontests/admin_scripts | |
| parent | 959a3f9791d780062c4efe8765404a8ef95e87f0 (diff) | |
| parent | ab6cd1c839b136cbc94178da433b2e97ab7f6061 (diff) | |
Merge branch 'master' of github.com:django/django into schema-alteration
Conflicts:
django/db/backends/postgresql_psycopg2/base.py
Diffstat (limited to 'tests/regressiontests/admin_scripts')
3 files changed, 30 insertions, 0 deletions
diff --git a/tests/regressiontests/admin_scripts/custom_templates/project_template/additional_dir/extra.py b/tests/regressiontests/admin_scripts/custom_templates/project_template/additional_dir/extra.py new file mode 100644 index 0000000000..6b553f190f --- /dev/null +++ b/tests/regressiontests/admin_scripts/custom_templates/project_template/additional_dir/extra.py @@ -0,0 +1 @@ +# this file uses the {{ extra }} variable diff --git a/tests/regressiontests/admin_scripts/management/commands/custom_startproject.py b/tests/regressiontests/admin_scripts/management/commands/custom_startproject.py new file mode 100644 index 0000000000..80c6d6b805 --- /dev/null +++ b/tests/regressiontests/admin_scripts/management/commands/custom_startproject.py @@ -0,0 +1,11 @@ +from optparse import make_option + +from django.core.management.commands.startproject import Command as BaseCommand + + +class Command(BaseCommand): + option_list = BaseCommand.option_list + ( + make_option('--extra', + action='store', dest='extra', + help='An arbitrary extra value passed to the context'), + ) diff --git a/tests/regressiontests/admin_scripts/tests.py b/tests/regressiontests/admin_scripts/tests.py index ecb16df53a..546fa7d79c 100644 --- a/tests/regressiontests/admin_scripts/tests.py +++ b/tests/regressiontests/admin_scripts/tests.py @@ -1541,6 +1541,24 @@ class StartProject(LiveServerTestCase, AdminScriptTestCase): self.assertIn("project_name = 'another_project'", content) self.assertIn("project_directory = '%s'" % testproject_dir, content) + def test_no_escaping_of_project_variables(self): + "Make sure template context variables are not html escaped" + # We're using a custom command so we need the alternate settings + self.write_settings('alternate_settings.py') + template_path = os.path.join(test_dir, 'admin_scripts', 'custom_templates', 'project_template') + args = ['custom_startproject', '--template', template_path, 'another_project', 'project_dir', '--extra', '<&>', '--settings=alternate_settings'] + testproject_dir = os.path.join(test_dir, 'project_dir') + os.mkdir(testproject_dir) + out, err = self.run_manage(args) + self.addCleanup(shutil.rmtree, testproject_dir) + self.assertNoOutput(err) + test_manage_py = os.path.join(testproject_dir, 'additional_dir', 'extra.py') + with open(test_manage_py, 'r') as fp: + content = fp.read() + self.assertIn("<&>", content) + # tidy up alternate settings + self.remove_settings('alternate_settings.py') + def test_custom_project_destination_missing(self): """ Make sure an exception is raised when the provided |
