[Python-checkins] python/dist/src/Lib/test test_codeccallbacks.py, 1.12, 1.13

doerwalter at users.sourceforge.net doerwalter at users.sourceforge.net
Tue Aug 12 11:32:45 EDT 2003


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv14601/Lib/test

Modified Files:
	test_codeccallbacks.py 
Log Message:
Enhance message for UnicodeEncodeError and UnicodeTranslateError.
If there is only one bad character it will now be printed in a
form that is a valid Python string.


Index: test_codeccallbacks.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_codeccallbacks.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** test_codeccallbacks.py	1 May 2003 17:45:36 -0000	1.12
--- test_codeccallbacks.py	12 Aug 2003 17:32:43 -0000	1.13
***************
*** 259,263 ****
              UnicodeEncodeError,
              ["ascii", u"g\xfcrk", 1, 2, "ouch"],
!             "'ascii' codec can't encode character '\ufc' in position 1: ouch"
          )
          self.check_exceptionobjectargs(
--- 259,263 ----
              UnicodeEncodeError,
              ["ascii", u"g\xfcrk", 1, 2, "ouch"],
!             "'ascii' codec can't encode character '\\xfc' in position 1: ouch"
          )
          self.check_exceptionobjectargs(
***************
*** 269,274 ****
              UnicodeEncodeError,
              ["ascii", u"\xfcx", 0, 1, "ouch"],
!             "'ascii' codec can't encode character '\ufc' in position 0: ouch"
          )
  
      def test_unicodedecodeerror(self):
--- 269,290 ----
              UnicodeEncodeError,
              ["ascii", u"\xfcx", 0, 1, "ouch"],
!             "'ascii' codec can't encode character '\\xfc' in position 0: ouch"
!         )
!         self.check_exceptionobjectargs(
!             UnicodeEncodeError,
!             ["ascii", u"\u0100x", 0, 1, "ouch"],
!             "'ascii' codec can't encode character '\\u0100' in position 0: ouch"
          )
+         self.check_exceptionobjectargs(
+             UnicodeEncodeError,
+             ["ascii", u"\uffffx", 0, 1, "ouch"],
+             "'ascii' codec can't encode character '\\uffff' in position 0: ouch"
+         )
+         if sys.maxunicode > 0xffff:
+             self.check_exceptionobjectargs(
+                 UnicodeEncodeError,
+                 ["ascii", u"\U00010000x", 0, 1, "ouch"],
+                 "'ascii' codec can't encode character '\\U00010000' in position 0: ouch"
+             )
  
      def test_unicodedecodeerror(self):
***************
*** 288,293 ****
              UnicodeTranslateError,
              [u"g\xfcrk", 1, 2, "ouch"],
!             "can't translate character '\\ufc' in position 1: ouch"
          )
          self.check_exceptionobjectargs(
              UnicodeTranslateError,
--- 304,325 ----
              UnicodeTranslateError,
              [u"g\xfcrk", 1, 2, "ouch"],
!             "can't translate character '\\xfc' in position 1: ouch"
!         )
!         self.check_exceptionobjectargs(
!             UnicodeTranslateError,
!             [u"g\u0100rk", 1, 2, "ouch"],
!             "can't translate character '\\u0100' in position 1: ouch"
          )
+         self.check_exceptionobjectargs(
+             UnicodeTranslateError,
+             [u"g\uffffrk", 1, 2, "ouch"],
+             "can't translate character '\\uffff' in position 1: ouch"
+         )
+         if sys.maxunicode > 0xffff:
+             self.check_exceptionobjectargs(
+                 UnicodeTranslateError,
+                 [u"g\U00010000rk", 1, 2, "ouch"],
+                 "can't translate character '\\U00010000' in position 1: ouch"
+             )
          self.check_exceptionobjectargs(
              UnicodeTranslateError,





More information about the Python-checkins mailing list