[Python-checkins] r46232 - python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py

sean.reifschneider python-checkins at python.org
Thu May 25 20:07:51 CEST 2006


Author: sean.reifschneider
Date: Thu May 25 20:07:50 2006
New Revision: 46232

Modified:
   python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py
Log:
Adding some tests Richard requested.


Modified: python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py
==============================================================================
--- python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py	(original)
+++ python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py	Thu May 25 20:07:50 2006
@@ -208,8 +208,10 @@
 unlink(TESTFN)
 
 #  test that exception attributes are happy.
+try: str(u'Hello \u00E1')
+except Exception, e: sampleUnicodeEncodeError = e
 try: unicode('\xff')
-except Exception, e: sampleUnicodeError = e
+except Exception, e: sampleUnicodeDecodeError = e
 exceptionList = [
         ( BaseException, (), { 'message' : '', 'args' : () }),
         ( BaseException, (1, ), { 'message' : 1, 'args' : ( 1, ) }),
@@ -245,7 +247,14 @@
                     'print_file_and_line' : None, 'msg' : 'msgStr',
                     'filename' : None, 'lineno' : None, 'offset' : None,
                     'text' : None }),
-        ( sampleUnicodeError,
+        ( UnicodeError, ( ),
+                { 'message' : '', 'args' : (), }),
+        ( sampleUnicodeEncodeError,
+                { 'message' : '', 'args' : ('ascii', u'Hello \xe1', 6, 7,
+                        'ordinal not in range(128)'),
+                    'encoding' : 'ascii', 'object' : u'Hello \xe1',
+                    'start' : 6, 'reason' : 'ordinal not in range(128)' }),
+        ( sampleUnicodeDecodeError,
                 { 'message' : '', 'args' : ('ascii', '\xff', 0, 1,
                         'ordinal not in range(128)'),
                     'encoding' : 'ascii', 'object' : '\xff',
@@ -271,7 +280,7 @@
         else: raise apply(args[0], args[1])
     except BaseException, e:
         for checkArgName in expected.keys():
-            if getattr(e, checkArgName) != expected[checkArgName]:
+            if repr(getattr(e, checkArgName)) != repr(expected[checkArgName]):
                 raise TestFailed('Checking exception arguments, exception '
                         '"%s", attribute "%s" expected %s got %s.' %
                         ( repr(e), checkArgName,


More information about the Python-checkins mailing list