Commits

Amaury Forgeot d'Arc committed f01df61

Fix most of the tests for the exception module

Comments (0)

Files changed (2)

pypy/module/exceptions/interp_exceptions.py

         space.realunicode_w(w_object)
         space.int_w(w_start)
         space.int_w(w_end)
-        space.realstr_w(w_reason)
+        space.str_w(w_reason)
         # assign attributes
         self.w_object = w_object
         self.w_start = w_start
 
     def descr_init(self, space, w_encoding, w_object, w_start, w_end, w_reason):
         # typechecking
-        space.realstr_w(w_encoding)
+        space.str_w(w_encoding)
         space.realunicode_w(w_object)
         space.int_w(w_start)
         space.int_w(w_end)
-        space.realstr_w(w_reason)
+        space.str_w(w_reason)
         # assign attributes
         self.w_encoding = w_encoding
         self.w_object = w_object

pypy/module/exceptions/test/test_exc.py

         del x.message
         assert not hasattr(x, "message")
 
-    def test_unicode_message(self):
-        assert unicode(Exception(u"\xe1")) == u"\xe1"
-        class E(BaseException):
-            def __str__(self):
-                return u"\xe1"
-        e = E()
-        assert unicode(e) == u"\xe1"
-
     def test_kwargs(self):
         from exceptions import Exception
         class X(Exception):
 
     def test_unicode_decode_error(self):
         from exceptions import UnicodeDecodeError
-        ud = UnicodeDecodeError("x", "y", 1, 5, "bah")
+        ud = UnicodeDecodeError("x", b"y", 1, 5, "bah")
         assert ud.encoding == 'x'
-        assert ud.object == 'y'
+        assert ud.object == b'y'
         assert ud.start == 1
         assert ud.end == 5
         assert ud.reason == 'bah'
-        assert ud.args == ('x', 'y', 1, 5, 'bah')
+        assert ud.args == ('x', b'y', 1, 5, 'bah')
         assert ud.message == ''
         ud.object = 'z9'
         assert ud.object == 'z9'
         assert str(ue) == "'x' codec can't encode character u'\\x39' in position 1: bah"
         ue.object = []
         assert ue.object == []
-        raises(TypeError, UnicodeEncodeError, "x", "y", 1, 5, "bah")
-        raises(TypeError, UnicodeEncodeError, u"x", u"y", 1, 5, "bah")
+        raises(TypeError, UnicodeEncodeError, "x", b"y", 1, 5, "bah")
 
     def test_multiple_inheritance(self):
         from exceptions import LookupError, ValueError, Exception, IOError
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.