Fixed #32734 -- Fixed validation of startapp's directory with trailing slash.
Regression in fc9566d42d
.
This commit is contained in:
parent
29345aecf6
commit
530f58caaa
1
AUTHORS
1
AUTHORS
|
@ -798,6 +798,7 @@ answer newbie questions, and generally made Django that much better:
|
|||
Rob Nguyen <tienrobertnguyenn@gmail.com>
|
||||
Robin Munn <http://www.geekforgod.com/>
|
||||
Rodrigo Pinheiro Marques de Araújo <fenrrir@gmail.com>
|
||||
Rohith P R <https://rohithpr.com>
|
||||
Romain Garrigues <romain.garrigues.cs@gmail.com>
|
||||
Ronny Haryanto <https://ronny.haryan.to/>
|
||||
Ross Poulton <ross@rossp.org>
|
||||
|
|
|
@ -73,9 +73,9 @@ class TemplateCommand(BaseCommand):
|
|||
except OSError as e:
|
||||
raise CommandError(e)
|
||||
else:
|
||||
if app_or_project == 'app':
|
||||
self.validate_name(os.path.basename(target), 'directory')
|
||||
top_dir = os.path.abspath(os.path.expanduser(target))
|
||||
if app_or_project == 'app':
|
||||
self.validate_name(os.path.basename(top_dir), 'directory')
|
||||
if not os.path.exists(top_dir):
|
||||
raise CommandError("Destination directory '%s' does not "
|
||||
"exist, please create it first." % top_dir)
|
||||
|
|
|
@ -2206,6 +2206,13 @@ class StartApp(AdminScriptTestCase):
|
|||
"another directory."
|
||||
)
|
||||
|
||||
def test_trailing_slash_in_target_app_directory_name(self):
|
||||
app_dir = os.path.join(self.test_dir, 'apps', 'app1')
|
||||
os.makedirs(app_dir)
|
||||
_, err = self.run_django_admin(['startapp', 'app', os.path.join('apps', 'app1', '')])
|
||||
self.assertNoOutput(err)
|
||||
self.assertIs(os.path.exists(os.path.join(app_dir, 'apps.py')), True)
|
||||
|
||||
def test_overlaying_app(self):
|
||||
# Use a subdirectory so it is outside the PYTHONPATH.
|
||||
os.makedirs(os.path.join(self.test_dir, 'apps/app1'))
|
||||
|
|
Loading…
Reference in New Issue