[pypy-svn] r10866 - in pypy/dist/pypy/objspace/std: . test

pedronis at codespeak.net pedronis at codespeak.net
Tue Apr 19 19:36:19 CEST 2005


Author: pedronis
Date: Tue Apr 19 19:36:19 2005
New Revision: 10866

Modified:
   pypy/dist/pypy/objspace/std/strutil.py
   pypy/dist/pypy/objspace/std/test/test_strutil.py
Log:
change the tests, ParseStringError does not need to be a subclass of ValueError anymore



Modified: pypy/dist/pypy/objspace/std/strutil.py
==============================================================================
--- pypy/dist/pypy/objspace/std/strutil.py	(original)
+++ pypy/dist/pypy/objspace/std/strutil.py	Tue Apr 19 19:36:19 2005
@@ -18,9 +18,8 @@
 class InvalidLiteral(Exception):
     pass
 
-class ParseStringError(ValueError):
+class ParseStringError(Exception):
     def __init__(self, msg):
-        self.args = (msg,)
         self.msg = msg
 
 def _parse_string(s, literal, base, fname):
@@ -70,7 +69,7 @@
 def string_to_int(s, base=10):
     """Utility to converts a string to an integer (or possibly a long).
     If base is 0, the proper base is guessed based on the leading
-    characters of 's'.  Raises ParseStringError (a subclass of ValueError) in case of error.
+    characters of 's'.  Raises ParseStringError in case of error.
     """
     s = literal = strip_spaces(s)
     return _parse_string(s, literal, base, 'int')

Modified: pypy/dist/pypy/objspace/std/test/test_strutil.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_strutil.py	(original)
+++ pypy/dist/pypy/objspace/std/test/test_strutil.py	Tue Apr 19 19:36:19 2005
@@ -76,11 +76,11 @@
                  '@',
                  ]
         for s in cases:
-            raises(ValueError, string_to_int, s)
-            raises(ValueError, string_to_int, '  '+s)
-            raises(ValueError, string_to_int, s+'  ')
-            raises(ValueError, string_to_int, '+'+s)
-            raises(ValueError, string_to_int, '-'+s)
+            raises(ParseStringError, string_to_int, s)
+            raises(ParseStringError, string_to_int, '  '+s)
+            raises(ParseStringError, string_to_int, s+'  ')
+            raises(ParseStringError, string_to_int, '+'+s)
+            raises(ParseStringError, string_to_int, '-'+s)
 
     def test_string_to_int_base_error(self):
         cases = [('1', 1),
@@ -98,17 +98,17 @@
                  ('12.3', 16),
                  ]
         for s, base in cases:
-            raises(ValueError, string_to_int, s, base)
-            raises(ValueError, string_to_int, '  '+s, base)
-            raises(ValueError, string_to_int, s+'  ', base)
-            raises(ValueError, string_to_int, '+'+s, base)
-            raises(ValueError, string_to_int, '-'+s, base)
+            raises(ParseStringError, string_to_int, s, base)
+            raises(ParseStringError, string_to_int, '  '+s, base)
+            raises(ParseStringError, string_to_int, s+'  ', base)
+            raises(ParseStringError, string_to_int, '+'+s, base)
+            raises(ParseStringError, string_to_int, '-'+s, base)
 
     def test_string_to_long(self):
         assert string_to_long('123L') == 123
         assert string_to_long('123L  ') == 123
-        raises(ValueError, string_to_long, 'L')
-        raises(ValueError, string_to_long, 'L  ')
+        raises(ParseStringError, string_to_long, 'L')
+        raises(ParseStringError, string_to_long, 'L  ')
         assert string_to_long('123L', 4) == 27
         assert string_to_long('123L', 30) == 27000 + 1800 + 90 + 21
         assert string_to_long('123L', 22) == 10648 + 968 + 66 + 21



More information about the Pypy-commit mailing list