          # We can use the management command to create a superuser
          # We skip validation because the temporary substitution of the
          # swappable User model messes with validation.
          new_io = StringIO()
          with self.assertRaises(CommandError):
              call_command(
                  "createsuperuser",
                  interactive=False,
                  stdout=new_io,
                  stderr=new_io,
 
</s> remove         with self.assertRaises(ValueError):
 </s> add         msg = 'Cannot force an update in save() with no primary key.'
        with self.assertRaisesMessage(ValueError, msg): </s> remove         with self.assertRaises(AssertionError):
 </s> add         msg = (
            "earliest() and latest() require either a field_name parameter or "
            "'get_latest_by' in the model"
        )
        with self.assertRaisesMessage(AssertionError, msg): </s> remove         with self.assertRaises(NotImplementedError):
 </s> add         with self.assertRaisesMessage(NotImplementedError, msg): </s> remove         with self.assertRaises(NotImplementedError):
 </s> add         msg = 'aggregate() + distinct(fields) not implemented.'
        with self.assertRaisesMessage(NotImplementedError, msg): </s> remove         with self.assertRaises(IntegrityError):
 </s> add         msg = (
            "Cannot delete some instances of model 'R' because they are "
            "referenced through a protected foreign key: 'A.protect'"
        )
        with self.assertRaisesMessage(IntegrityError, msg):
        with self.assertRaisesMessage(CommandError, 'You must use --email with --noinput.'):
          # We can use the management command to create a superuser
          # We skip validation because the temporary substitution of the
          # swappable User model messes with validation.
          new_io = StringIO()
        with self.assertRaisesMessage(CommandError, 'You must use --email with --noinput.'):
              call_command(
                  "createsuperuser",
                  interactive=False,
                  stdout=new_io,
                  stderr=new_io,
keep keep keep keep replace keep keep keep keep keep
 Used assertRaisesMessage() to test Django's error messages. 
tests/auth_tests/test_management.py