1212# results for each Python version rather than writing a generic "works for both" test suite
1313if PY2 :
1414 class TestCompatPY2 (object ):
15+
1516 def test_to_unicode_string (self ):
16- """ Calling `compat.to_unicode` on a non-unicode string """
17+ # Calling `compat.to_unicode` on a non-unicode string
1718 res = to_unicode ('test' )
1819 eq_ (type (res ), unicode )
1920 eq_ (res , 'test' )
2021
2122 def test_to_unicode_unicode_encoded (self ):
22- """ Calling `compat.to_unicode` on a unicode encoded string """
23+ # Calling `compat.to_unicode` on a unicode encoded string
2324 res = to_unicode ('\xc3 \xbf ' )
2425 eq_ (type (res ), unicode )
2526 eq_ (res , u'ÿ' )
2627
2728 def test_to_unicode_unicode_double_decode (self ):
28- """ Calling `compat.to_unicode` on a unicode decoded string """
29+ # Calling `compat.to_unicode` on a unicode decoded string
2930 # This represents the double-decode issue, which can cause a `UnicodeEncodeError`
3031 # `'\xc3\xbf'.decode('utf-8').decode('utf-8')`
3132 res = to_unicode ('\xc3 \xbf ' .decode ('utf-8' ))
3233 eq_ (type (res ), unicode )
3334 eq_ (res , u'ÿ' )
3435
3536 def test_to_unicode_unicode_string (self ):
36- """ Calling `compat.to_unicode` on a unicode string """
37+ # Calling `compat.to_unicode` on a unicode string
3738 res = to_unicode (u'ÿ' )
3839 eq_ (type (res ), unicode )
3940 eq_ (res , u'ÿ' )
4041
4142 def test_to_unicode_bytearray (self ):
42- """ Calling `compat.to_unicode` with a `bytearray` containing unicode """
43+ # Calling `compat.to_unicode` with a `bytearray` containing unicode
4344 res = to_unicode (bytearray ('\xc3 \xbf ' ))
4445 eq_ (type (res ), unicode )
4546 eq_ (res , u'ÿ' )
4647
4748 def test_to_unicode_bytearray_double_decode (self ):
48- """ Calling `compat.to_unicode` with an already decoded `bytearray` """
49+ # Calling `compat.to_unicode` with an already decoded `bytearray`
4950 # This represents the double-decode issue, which can cause a `UnicodeEncodeError`
5051 # `bytearray('\xc3\xbf').decode('utf-8').decode('utf-8')`
5152 res = to_unicode (bytearray ('\xc3 \xbf ' ).decode ('utf-8' ))
5253 eq_ (type (res ), unicode )
5354 eq_ (res , u'ÿ' )
5455
5556 def test_to_unicode_non_string (self ):
56- """ Calling `compat.to_unicode` on non-string types """
57+ # Calling `compat.to_unicode` on non-string types
5758 eq_ (to_unicode (1 ), u'1' )
5859 eq_ (to_unicode (True ), u'True' )
5960 eq_ (to_unicode (None ), u'None' )
@@ -62,31 +63,31 @@ def test_to_unicode_non_string(self):
6263else :
6364 class TestCompatPY3 (object ):
6465 def test_to_unicode_string (self ):
65- """ Calling `compat.to_unicode` on a non-unicode string """
66+ # Calling `compat.to_unicode` on a non-unicode string
6667 res = to_unicode ('test' )
6768 eq_ (type (res ), str )
6869 eq_ (res , 'test' )
6970
7071 def test_to_unicode_unicode_encoded (self ):
71- """ Calling `compat.to_unicode` on a unicode encoded string """
72+ # Calling `compat.to_unicode` on a unicode encoded string
7273 res = to_unicode ('\xff ' )
7374 eq_ (type (res ), str )
7475 eq_ (res , 'ÿ' )
7576
7677 def test_to_unicode_unicode_string (self ):
77- """ Calling `compat.to_unicode` on a unicode string """
78+ # Calling `compat.to_unicode` on a unicode string
7879 res = to_unicode ('ÿ' )
7980 eq_ (type (res ), str )
8081 eq_ (res , 'ÿ' )
8182
8283 def test_to_unicode_bytearray (self ):
83- """ Calling `compat.to_unicode` with a `bytearray` containing unicode """
84+ # Calling `compat.to_unicode` with a `bytearray` containing unicode """
8485 res = to_unicode (bytearray ('\xff ' , 'utf-8' ))
8586 eq_ (type (res ), str )
8687 eq_ (res , 'ÿ' )
8788
8889 def test_to_unicode_non_string (self ):
89- """ Calling `compat.to_unicode` on non-string types """
90+ # Calling `compat.to_unicode` on non-string types
9091 eq_ (to_unicode (1 ), '1' )
9192 eq_ (to_unicode (True ), 'True' )
9293 eq_ (to_unicode (None ), 'None' )
0 commit comments