diff options
| author | Yoong Kang Lim <yoongkang.lim@gmail.com> | 2015-10-22 22:33:59 +1100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-10-22 13:01:07 -0400 |
| commit | 3f300efede9f9670f4c413ff85ad731def15992b (patch) | |
| tree | 0618ad15e0c26601a6f7f532f596408e56e5c647 /tests/admin_scripts/tests.py | |
| parent | ee66d8dd7df8326c453fd04c2bdeb5225df934be (diff) | |
Fixed #25589 -- Allowed startapp/project to create apps with Unicode characters in the name.
Diffstat (limited to 'tests/admin_scripts/tests.py')
| -rw-r--r-- | tests/admin_scripts/tests.py | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py index 4e976d89fd..f2950f0ee6 100644 --- a/tests/admin_scripts/tests.py +++ b/tests/admin_scripts/tests.py @@ -31,7 +31,7 @@ from django.test import ( from django.test.runner import DiscoverRunner from django.utils._os import npath, upath from django.utils.encoding import force_text -from django.utils.six import PY3, StringIO +from django.utils.six import PY2, PY3, StringIO custom_templates_dir = os.path.join(os.path.dirname(upath(__file__)), 'custom_templates') @@ -633,6 +633,20 @@ class DjangoAdminSettingsDirectory(AdminScriptTestCase): self.assertTrue(os.path.exists(app_path)) self.assertTrue(os.path.exists(os.path.join(app_path, 'api.py'))) + @unittest.skipIf(PY2, "Python 2 doesn't support Unicode package names.") + def test_startapp_unicode_name(self): + "directory: startapp creates the correct directory with unicode characters" + args = ['startapp', 'こんにちは'] + app_path = os.path.join(self.test_dir, 'こんにちは') + out, err = self.run_django_admin(args, 'test_project.settings') + self.addCleanup(shutil.rmtree, app_path) + self.assertNoOutput(err) + self.assertTrue(os.path.exists(app_path)) + with open(os.path.join(app_path, 'apps.py'), 'r') as f: + content = f.read() + self.assertIn("class こんにちはConfig(AppConfig)", content) + self.assertIn("name = 'こんにちは'", content) + def test_builtin_command(self): "directory: django-admin builtin commands fail with an error when no settings provided" args = ['check', 'admin_scripts'] @@ -1887,8 +1901,18 @@ class StartProject(LiveServerTestCase, AdminScriptTestCase): self.addCleanup(shutil.rmtree, testproject_dir, True) 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) + if PY2: + self.assertOutput( + err, + "Error: '%s' is not a valid project name. Please make " + "sure the name begins with a letter or underscore." % bad_name + ) + else: + 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_simple_project_different_directory(self): |
