summaryrefslogtreecommitdiff
path: root/tests/auth_tests/test_management.py
diff options
context:
space:
mode:
authorHasan Ramezani <hasan.r67@gmail.com>2017-09-12 23:17:07 +0430
committerTim Graham <timograham@gmail.com>2017-10-09 21:49:35 -0400
commit6aec130a4c19ed17a61835af15b4fb2186dfacad (patch)
treeac501febb66d7cfece1d2edce91a9d5d8ce2222f /tests/auth_tests/test_management.py
parent22ff4f81b1859ed7af7999ef479a10b5d31a2164 (diff)
Fixed #28591 -- Added an error message for createsuperuser --username= (blank).
Diffstat (limited to 'tests/auth_tests/test_management.py')
-rw-r--r--tests/auth_tests/test_management.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/auth_tests/test_management.py b/tests/auth_tests/test_management.py
index c43091d932..5463707dad 100644
--- a/tests/auth_tests/test_management.py
+++ b/tests/auth_tests/test_management.py
@@ -523,6 +523,22 @@ class CreatesuperuserManagementCommandTestCase(TestCase):
test(self)
+ def test_blank_username(self):
+ """Creation fails if --username is blank."""
+ new_io = StringIO()
+
+ def test(self):
+ with self.assertRaisesMessage(CommandError, 'Username cannot be blank.'):
+ call_command(
+ 'createsuperuser',
+ username='',
+ stdin=MockTTY(),
+ stdout=new_io,
+ stderr=new_io,
+ )
+
+ test(self)
+
def test_invalid_username(self):
"""Creation fails if the username fails validation."""
user_field = User._meta.get_field(User.USERNAME_FIELD)