- if six.PY2:
- self.assertEqual(util.uri_decode_pathname("sample%20ext%c3%a9nded"),
- b"sample ext\xc3\xa9nded")
- self.assertEqual(util.uri_decode_pathname("sample%20exténded"),
- b"sample ext\xc3\xa9nded")
- # In Python 2, non-UTF-8 sequences are just passed through as
- # bytestrings.
- self.assertEqual(util.uri_decode_pathname(b"inv%e1lid"),
- b"inv\xe1lid")
- self.assertEqual(util.uri_decode_pathname(b"inv\xe1lid"),
- b"inv\xe1lid")
- elif six.PY3:
- self.assertEqual(util.uri_decode_pathname("sample%20ext%c3%a9nded"),
- "sample exténded")
- self.assertEqual(util.uri_decode_pathname("sample%20exténded"),
- "sample exténded")
- # In Python 3, non-UTF-8 sequences are represented using surrogate
- # escapes to allow lossless conversion back to the appropriate
- # bytestring.
- self.assertEqual(util.uri_decode_pathname("inv%e1lid"),
- "inv\udce1lid")
- self.assertEqual(
- util.pathname_to_bytes(util.uri_decode_pathname("inv%e1lid")),
- b"inv\xe1lid")
+ self.assertEqual(util.uri_decode_pathname("sample%20ext%c3%a9nded"),
+ "sample exténded")
+ self.assertEqual(util.uri_decode_pathname("sample%20exténded"),
+ "sample exténded")
+ # In Python 3, non-UTF-8 sequences are represented using surrogate
+ # escapes to allow lossless conversion back to the appropriate
+ # bytestring.
+ self.assertEqual(util.uri_decode_pathname("inv%e1lid"),
+ "inv\udce1lid")
+ self.assertEqual(
+ util.pathname_to_bytes(util.uri_decode_pathname("inv%e1lid")),
+ b"inv\xe1lid")