  
      available_apps = ['transactions']
  
      def test_atomic_prevents_setting_autocommit(self):
          autocommit = transaction.get_autocommit()
          with transaction.atomic():
              with self.assertRaisesMessage(transaction.TransactionManagementError, self.forbidden_atomic_msg):
                  transaction.set_autocommit(not autocommit)
 
</s> remove             with self.assertRaises(transaction.TransactionManagementError):
 </s> add             with self.assertRaisesMessage(transaction.TransactionManagementError, self.forbidden_atomic_msg): </s> remove             with self.assertRaises(transaction.TransactionManagementError):
 </s> add             with self.assertRaisesMessage(transaction.TransactionManagementError, self.forbidden_atomic_msg): </s> remove             with self.assertRaises(transaction.TransactionManagementError):
 </s> add             with self.assertRaisesMessage(transaction.TransactionManagementError, self.forbidden_atomic_msg): </s> remove             with self.assertRaises(FieldError):
 </s> add             msg = "Joined field references are not permitted in this query"
            with self.assertRaisesMessage(FieldError, msg): </s> remove             with self.assertRaises(transaction.TransactionManagementError):
 </s> add             msg = (
                "An error occurred in the current transaction. You can't "
                "execute queries until the end of the 'atomic' block."
            )
            with self.assertRaisesMessage(transaction.TransactionManagementError, msg):
    forbidden_atomic_msg = "This is forbidden when an 'atomic' block is active."
  
      available_apps = ['transactions']
    forbidden_atomic_msg = "This is forbidden when an 'atomic' block is active."
  
      def test_atomic_prevents_setting_autocommit(self):
          autocommit = transaction.get_autocommit()
          with transaction.atomic():
              with self.assertRaisesMessage(transaction.TransactionManagementError, self.forbidden_atomic_msg):
                  transaction.set_autocommit(not autocommit)
keep add keep keep keep keep keep keep
 Used assertRaisesMessage() to test Django's error messages. 
tests/transactions/tests.py