Removed unnecessary inner methods in CreatesuperuserManagementCommandTestCase.
This commit is contained in:
parent
b4068bc656
commit
a0df5dea33
|
@ -707,34 +707,26 @@ class CreatesuperuserManagementCommandTestCase(TestCase):
|
|||
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)
|
||||
with self.assertRaisesMessage(CommandError, 'Username cannot be blank.'):
|
||||
call_command(
|
||||
'createsuperuser',
|
||||
username='',
|
||||
stdin=MockTTY(),
|
||||
stdout=new_io,
|
||||
stderr=new_io,
|
||||
)
|
||||
|
||||
def test_blank_username_non_interactive(self):
|
||||
new_io = StringIO()
|
||||
|
||||
def test(self):
|
||||
with self.assertRaisesMessage(CommandError, 'Username cannot be blank.'):
|
||||
call_command(
|
||||
'createsuperuser',
|
||||
username='',
|
||||
interactive=False,
|
||||
stdin=MockTTY(),
|
||||
stdout=new_io,
|
||||
stderr=new_io,
|
||||
)
|
||||
|
||||
test(self)
|
||||
with self.assertRaisesMessage(CommandError, 'Username cannot be blank.'):
|
||||
call_command(
|
||||
'createsuperuser',
|
||||
username='',
|
||||
interactive=False,
|
||||
stdin=MockTTY(),
|
||||
stdout=new_io,
|
||||
stderr=new_io,
|
||||
)
|
||||
|
||||
def test_password_validation_bypass(self):
|
||||
"""
|
||||
|
@ -952,19 +944,15 @@ class CreatesuperuserManagementCommandTestCase(TestCase):
|
|||
@override_settings(AUTH_USER_MODEL='auth_tests.NoPasswordUser')
|
||||
def test_usermodel_without_password(self):
|
||||
new_io = StringIO()
|
||||
|
||||
def test(self):
|
||||
call_command(
|
||||
'createsuperuser',
|
||||
interactive=False,
|
||||
stdin=MockTTY(),
|
||||
stdout=new_io,
|
||||
stderr=new_io,
|
||||
username='username',
|
||||
)
|
||||
self.assertEqual(new_io.getvalue().strip(), 'Superuser created successfully.')
|
||||
|
||||
test(self)
|
||||
call_command(
|
||||
'createsuperuser',
|
||||
interactive=False,
|
||||
stdin=MockTTY(),
|
||||
stdout=new_io,
|
||||
stderr=new_io,
|
||||
username='username',
|
||||
)
|
||||
self.assertEqual(new_io.getvalue().strip(), 'Superuser created successfully.')
|
||||
|
||||
@override_settings(AUTH_USER_MODEL='auth_tests.NoPasswordUser')
|
||||
def test_usermodel_without_password_interactive(self):
|
||||
|
|
Loading…
Reference in New Issue