Fixed #28591 -- Added an error message for createsuperuser --username= (blank).

This commit is contained in:
Hasan Ramezani 2017-09-12 23:17:07 +04:30 committed by Tim Graham
parent 22ff4f81b1
commit 6aec130a4c
2 changed files with 20 additions and 1 deletions

View file

@ -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)