1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #19125 -- The startproject command should validate the name earlier

Thanks Łukasz Rekucki for the report and the patch.
This commit is contained in:
Claude Paroz
2012-10-13 16:05:34 +02:00
parent 93e79b45bc
commit 9893fa12b7
4 changed files with 25 additions and 20 deletions

View File

@@ -1430,13 +1430,15 @@ class StartProject(LiveServerTestCase, AdminScriptTestCase):
def test_invalid_project_name(self):
"Make sure the startproject management command validates a project name"
args = ['startproject', '7testproject']
testproject_dir = os.path.join(test_dir, '7testproject')
self.addCleanup(shutil.rmtree, testproject_dir, True)
for bad_name in ('7testproject', '../testproject'):
args = ['startproject', bad_name]
testproject_dir = os.path.join(test_dir, bad_name)
self.addCleanup(shutil.rmtree, testproject_dir, True)
out, err = self.run_django_admin(args)
self.assertOutput(err, "Error: '7testproject' is not a valid project name. Please make sure the name begins with a letter or underscore.")
self.assertFalse(os.path.exists(testproject_dir))
out, err = self.run_django_admin(args)
self.assertOutput(err, "Error: '%s' is not a valid project name. "
"Please make sure the name begins with a letter or underscore." % bad_name)
self.assertFalse(os.path.exists(testproject_dir))
def test_simple_project_different_directory(self):
"Make sure the startproject management command creates a project in a specific directory"