From 6aec130a4c19ed17a61835af15b4fb2186dfacad Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Tue, 12 Sep 2017 23:17:07 +0430 Subject: Fixed #28591 -- Added an error message for createsuperuser --username= (blank). --- tests/auth_tests/test_management.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests') 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) -- cgit v1.3