  
      def test_session_key_is_read_only(self):
          def set_session_key(session):
              session.session_key = session._get_new_session_key()
          self.assertRaises(AttributeError, set_session_key, self.session)
  
      # Custom session expiry
      def test_default_expiry(self):
          # A normal session has a max age equal to settings
          self.assertEqual(self.session.get_expiry_age(), settings.SESSION_COOKIE_AGE)
 
</s> remove         self.assertRaises(IntegrityError, a.protect.delete)
 </s> add         with self.assertRaises(IntegrityError):
            a.protect.delete() </s> remove         self.assertRaises(Person.DoesNotExist, getattr, membership, 'person')
 </s> add         with self.assertRaises(Person.DoesNotExist):
            getattr(membership, 'person') </s> remove         self.assertRaises(AttributeError, lambda: Book.objects)
 </s> add         with self.assertRaises(AttributeError):
            Book.objects </s> remove         self.assertRaises(AttributeError, lambda: CommonInfo.objects.all())
 </s> add         with self.assertRaises(AttributeError):
            CommonInfo.objects.all() </s> remove         self.assertRaises(TypeError, delattr, settings, '_wrapped')
 </s> add         with self.assertRaises(TypeError):
            delattr(settings, '_wrapped')
        with self.assertRaises(AttributeError):
            set_session_key(self.session)
  
      def test_session_key_is_read_only(self):
          def set_session_key(session):
              session.session_key = session._get_new_session_key()
        with self.assertRaises(AttributeError):
            set_session_key(self.session)
  
      # Custom session expiry
      def test_default_expiry(self):
          # A normal session has a max age equal to settings
          self.assertEqual(self.session.get_expiry_age(), settings.SESSION_COOKIE_AGE)
keep keep keep keep replace keep keep keep keep keep
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/sessions_tests/tests.py