diff options
author | Jon Dufresne <jon.dufresne@gmail.com> | 2019-02-05 18:06:13 -0800 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2019-02-06 12:59:55 -0500 |
commit | 10b0fd15763a8f4ac08633f7b4c091d6340faf3a (patch) | |
tree | d1df223468f744850af5eb3ecca22177fb285b15 /tests/admin_scripts | |
parent | b709d701303b3877387020c1558a590713b09853 (diff) | |
download | django-10b0fd15763a8f4ac08633f7b4c091d6340faf3a.tar.gz |
Refs #27804 -- Used subTest() in admin_scripts invalid name tests.
Diffstat (limited to 'tests/admin_scripts')
-rw-r--r-- | tests/admin_scripts/tests.py | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py index ecfa267d07..1e5b0c6ad1 100644 --- a/tests/admin_scripts/tests.py +++ b/tests/admin_scripts/tests.py @@ -1893,16 +1893,17 @@ class StartProject(LiveServerTestCase, AdminScriptTestCase): def test_invalid_project_name(self): "Make sure the startproject management command validates a project name" for bad_name in ('7testproject', '../testproject'): - args = ['startproject', bad_name] - testproject_dir = os.path.join(self.test_dir, bad_name) - - out, err = self.run_django_admin(args) - self.assertOutput( - err, - "Error: '%s' is not a valid project name. Please make " - "sure the name is a valid identifier." % bad_name - ) - self.assertFalse(os.path.exists(testproject_dir)) + with self.subTest(project_name=bad_name): + args = ['startproject', bad_name] + testproject_dir = os.path.join(self.test_dir, bad_name) + + out, err = self.run_django_admin(args) + self.assertOutput( + err, + "Error: '%s' is not a valid project name. Please make " + "sure the name is a valid identifier." % bad_name + ) + self.assertFalse(os.path.exists(testproject_dir)) def test_importable_project_name(self): """ @@ -2095,16 +2096,17 @@ class StartApp(AdminScriptTestCase): def test_invalid_name(self): """startapp validates that app name is a valid Python identifier.""" for bad_name in ('7testproject', '../testproject'): - args = ['startapp', bad_name] - testproject_dir = os.path.join(self.test_dir, bad_name) - - out, err = self.run_django_admin(args) - self.assertOutput( - err, - "CommandError: '{}' is not a valid app name. Please make " - "sure the name is a valid identifier.".format(bad_name) - ) - self.assertFalse(os.path.exists(testproject_dir)) + with self.subTest(app_name=bad_name): + args = ['startapp', bad_name] + testproject_dir = os.path.join(self.test_dir, bad_name) + + out, err = self.run_django_admin(args) + self.assertOutput( + err, + "CommandError: '{}' is not a valid app name. Please make " + "sure the name is a valid identifier.".format(bad_name) + ) + self.assertFalse(os.path.exists(testproject_dir)) def test_importable_name(self): """ |