From 10b0fd15763a8f4ac08633f7b4c091d6340faf3a Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Tue, 5 Feb 2019 18:06:13 -0800 Subject: [PATCH] Refs #27804 -- Used subTest() in admin_scripts invalid name tests. --- tests/admin_scripts/tests.py | 38 +++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py index ecfa267d071..1e5b0c6ad1b 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) + 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)) + 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) + 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)) + 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): """