  
          # str(s) raises a TypeError on python 3 if the result is not a text type.
          # python 2 fails when it tries converting from str to unicode (via ASCII).
          exception = TypeError if six.PY3 else UnicodeError
          self.assertRaises(exception, force_text, MyString())
  
      def test_force_text_lazy(self):
          s = SimpleLazyObject(lambda: 'x')
          self.assertTrue(issubclass(type(force_text(s)), six.text_type))
  
 
</s> remove         self.assertRaises(TypeError, qs.gml, field_name='name')
 </s> add         with self.assertRaises(TypeError):
            qs.gml(field_name='name') </s> remove             self.assertRaises(GEOSException, fg._get_ptr)
 </s> add             with self.assertRaises(GEOSException):
                fg._get_ptr() </s> remove         self.assertRaises(TypeError, qs.kml, 'name')
 </s> add         with self.assertRaises(TypeError):
            qs.kml('name') </s> remove         self.assertRaises(IOError, lambda: file_move_safe(self.file_a, self.file_b, allow_overwrite=False))
 </s> add         with self.assertRaises(IOError):
            file_move_safe(self.file_a, self.file_b, allow_overwrite=False) </s> remove         self.assertRaises(ObjectDoesNotExist, Site.objects.get_current)
 </s> add         with self.assertRaises(ObjectDoesNotExist):
            Site.objects.get_current()
        with self.assertRaises(exception):
            force_text(MyString())
  
          # str(s) raises a TypeError on python 3 if the result is not a text type.
          # python 2 fails when it tries converting from str to unicode (via ASCII).
          exception = TypeError if six.PY3 else UnicodeError
        with self.assertRaises(exception):
            force_text(MyString())
  
      def test_force_text_lazy(self):
          s = SimpleLazyObject(lambda: 'x')
          self.assertTrue(issubclass(type(force_text(s)), six.text_type))
  
keep keep keep keep replace keep keep keep keep keep
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/utils_tests/test_encoding.py