@@ -111,6 +111,27 @@ def test_b64encode(self):
111111 eq (base64 .urlsafe_b64encode ('\xd3 V\xbe o\xf7 \x1d ' ), '01a-b_cd' )
112112 # Non-bytes
113113 eq (base64 .urlsafe_b64encode (bytearray ('\xd3 V\xbe o\xf7 \x1d ' )), '01a-b_cd' )
114+
115+ def test_b64encode_warns (self ):
116+ import warnings , base64
117+ with warnings .catch_warnings (record = True ) as w :
118+ warnings .simplefilter ('always' , UserWarning )
119+ base64 .b64encode (b'test' )
120+ self .assertTrue (any ('base64.b64encode returns str in Python 2 (bytes in 3.x)' == str (x .message ) for x in w ))
121+
122+ def test_b32encode_warns (self ):
123+ import warnings , base64
124+ with warnings .catch_warnings (record = True ) as w :
125+ warnings .simplefilter ('always' , UserWarning )
126+ base64 .b32encode (b'test' )
127+ self .assertTrue (any ('base64.b32encode returns str in Python 2 (bytes in 3.x)' == str (x .message ) for x in w ))
128+
129+ def test_b16encode_warns (self ):
130+ import warnings , base64
131+ with warnings .catch_warnings (record = True ) as w :
132+ warnings .simplefilter ('always' , UserWarning )
133+ base64 .b16encode (b'test' )
134+ self .assertTrue (any ('base64.b16encode returns str in Python 2 (bytes in 3.x)' == str (x .message ) for x in w ))
114135
115136 def test_b64decode (self ):
116137 eq = self .assertEqual
0 commit comments