          # fields shouldn't appear in the list when an error is made.
          self.assertRaisesMessage(
              FieldError,
              "Choices are: id, name, references, related, selfreferchild, selfreferchildsibling",
              lambda: SelfRefer.objects.filter(porcupine='fred')
          )
  
      def test_m2m_inheritance_symmetry(self):
          # Test to ensure that the relationship between two inherited models
          # with a self-referential m2m field maintains symmetry
  
 
</s> remove         self.assertRaisesMessage(
 </s> add         with self.assertRaisesMessage( </s> remove         self.assertRaisesMessage(
 </s> add         with self.assertRaisesMessage( </s> remove             Article.objects.dates,
            "invalid_field",
            "year",
        )
 </s> add         ):
            Article.objects.dates('invalid_field', 'year') </s> remove                 self.assertRaises(expected_exc, func)
 </s> add                 with self.assertRaises(expected_exc):
                    func() </s> remove                 self.assertRaisesMessage(expected_exc, msg, func)
 </s> add                 with self.assertRaisesMessage(expected_exc, msg):
                    func()
        ):
            SelfRefer.objects.filter(porcupine='fred')
          # fields shouldn't appear in the list when an error is made.
          self.assertRaisesMessage(
              FieldError,
              "Choices are: id, name, references, related, selfreferchild, selfreferchildsibling",
        ):
            SelfRefer.objects.filter(porcupine='fred')
        ):
            SelfRefer.objects.filter(porcupine='fred')
  
      def test_m2m_inheritance_symmetry(self):
          # Test to ensure that the relationship between two inherited models
          # with a self-referential m2m field maintains symmetry
  
keep keep keep keep replace replace keep keep keep keep keep
 Refs #26022 -- Used context manager version of assertRaisesMessage in tests.

Follow up to 253adc2b8a52982139d40c4f55b3fd446e1cb8f3. 
tests/m2m_regress/tests.py