summaryrefslogtreecommitdiff
path: root/tests/admin_scripts
diff options
context:
space:
mode:
authoroliver <myungsekyo@gmail.com>2019-04-25 11:28:31 +0900
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-04-25 08:52:48 +0200
commitfc9566d42daf28cdaa25a5db1b5ade253ceb064f (patch)
treeabce6e720765d3d5f1e64bce5288cbe0f0ba6f1a /tests/admin_scripts
parent0f22671ecb7e9555300fd2d6cb7bf6dc61735d07 (diff)
downloaddjango-fc9566d42daf28cdaa25a5db1b5ade253ceb064f.tar.gz
Fixed #30393 -- Added validation of startapp's directory option.
Diffstat (limited to 'tests/admin_scripts')
-rw-r--r--tests/admin_scripts/tests.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py
index f6fb42b1aa..08d188e88a 100644
--- a/tests/admin_scripts/tests.py
+++ b/tests/admin_scripts/tests.py
@@ -2132,6 +2132,25 @@ class StartApp(AdminScriptTestCase):
)
self.assertFalse(os.path.exists(testproject_dir))
+ def test_invalid_target_name(self):
+ for bad_target in ('invalid.dir_name', '7invalid_dir_name', '.invalid_dir_name'):
+ with self.subTest(bad_target):
+ _, err = self.run_django_admin(['startapp', 'app', bad_target])
+ self.assertOutput(
+ err,
+ "CommandError: '%s' is not a valid app directory. Please "
+ "make sure the directory is a valid identifier." % bad_target
+ )
+
+ def test_importable_target_name(self):
+ _, err = self.run_django_admin(['startapp', 'app', 'os'])
+ self.assertOutput(
+ err,
+ "CommandError: 'os' conflicts with the name of an existing Python "
+ "module and cannot be used as an app directory. Please try "
+ "another directory."
+ )
+
def test_overlaying_app(self):
self.run_django_admin(['startapp', 'app1'])
out, err = self.run_django_admin(['startapp', 'app2', 'app1'])