'Check the operation of the createsuperuser management command'

def test_createsuperuser_management_command(self):

    new_io = StringIO()
    call_command('createsuperuser', interactive=False, username='joe', email='joe@somewhere.org', stdout=new_io)
    command_output = new_io.getvalue().strip()
    self.assertEqual(command_output, 'Superuser    created    successfully.')
    u = User.objects.get(username='joe')
    self.assertEqual(u.email, 'joe@somewhere.org')
    self.assertFalse(u.has_usable_password())
    new_io = StringIO()
    call_command('createsuperuser', interactive=False, username='joe2', email='joe2@somewhere.org', verbosity=0, stdout=new_io)
    command_output = new_io.getvalue().strip()
    self.assertEqual(command_output, '')
    u = User.objects.get(username='joe2')
    self.assertEqual(u.email, 'joe2@somewhere.org')
    self.assertFalse(u.has_usable_password())
    new_io = StringIO()
    call_command('createsuperuser', interactive=False, username='joe+admin@somewhere.org', email='joe@somewhere.org', stdout=new_io)
    u = User.objects.get(username='joe+admin@somewhere.org')
    self.assertEqual(u.email, 'joe@somewhere.org')
    self.assertFalse(u.has_usable_password())
