Merge "Replace deprecated "decodestring()" by "decodebytes()""
This commit is contained in:
@@ -11,11 +11,11 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import base64
|
|
||||||
import json
|
import json
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
from oslo_serialization import base64
|
||||||
import six
|
import six
|
||||||
from six.moves.urllib import error
|
from six.moves.urllib import error
|
||||||
import testtools
|
import testtools
|
||||||
@@ -715,7 +715,7 @@ class TestGetTemplateContents(testtools.TestCase):
|
|||||||
'content': {'get_file': url},
|
'content': {'get_file': url},
|
||||||
'encoding': 'b64'}]}}}}}
|
'encoding': 'b64'}]}}}}}
|
||||||
with mock.patch('six.moves.urllib.request.urlopen') as mock_url:
|
with mock.patch('six.moves.urllib.request.urlopen') as mock_url:
|
||||||
raw_content = base64.decodestring(content)
|
raw_content = base64.decode_as_bytes(content)
|
||||||
response = six.BytesIO(raw_content)
|
response = six.BytesIO(raw_content)
|
||||||
mock_url.return_value = response
|
mock_url.return_value = response
|
||||||
files = {}
|
files = {}
|
||||||
@@ -732,8 +732,8 @@ t9SdXgLAAEE\n6AMAAATpAwAAaGVhdApQSwECHgMKAAAAAABGWVpEWzgLgQUAAAAF\
|
|||||||
AAAACAAYAAAAAAABAAAApIEA\nAAAAaGVhdC50eHRVVAUAAxRbDVN1eAsAAQToAwA\
|
AAAACAAYAAAAAAABAAAApIEA\nAAAAaGVhdC50eHRVVAUAAxRbDVN1eAsAAQToAwA\
|
||||||
ABOkDAABQSwUGAAAAAAEAAQBOAAAARwAAAAAA\n'''
|
ABOkDAABQSwUGAAAAAAEAAQBOAAAARwAAAAAA\n'''
|
||||||
# zip has '\0' in stream
|
# zip has '\0' in stream
|
||||||
self.assertIn(b'\0', base64.decodestring(content))
|
self.assertIn(b'\0', base64.decode_as_bytes(content))
|
||||||
decoded_content = base64.decodestring(content)
|
decoded_content = base64.decode_as_bytes(content)
|
||||||
if six.PY3:
|
if six.PY3:
|
||||||
self.assertRaises(UnicodeDecodeError, decoded_content.decode)
|
self.assertRaises(UnicodeDecodeError, decoded_content.decode)
|
||||||
else:
|
else:
|
||||||
@@ -748,8 +748,8 @@ ABOkDAABQSwUGAAAAAAEAAQBOAAAARwAAAAAA\n'''
|
|||||||
filename = 'heat.utf16'
|
filename = 'heat.utf16'
|
||||||
content = b'//4tTkhTCgA=\n'
|
content = b'//4tTkhTCgA=\n'
|
||||||
# utf6 has '\0' in stream
|
# utf6 has '\0' in stream
|
||||||
self.assertIn(b'\0', base64.decodestring(content))
|
self.assertIn(b'\0', base64.decode_as_bytes(content))
|
||||||
decoded_content = base64.decodestring(content)
|
decoded_content = base64.decode_as_bytes(content)
|
||||||
if six.PY3:
|
if six.PY3:
|
||||||
self.assertRaises(UnicodeDecodeError, decoded_content.decode)
|
self.assertRaises(UnicodeDecodeError, decoded_content.decode)
|
||||||
else:
|
else:
|
||||||
@@ -763,8 +763,8 @@ ABOkDAABQSwUGAAAAAAEAAQBOAAAARwAAAAAA\n'''
|
|||||||
filename = 'heat.gb18030'
|
filename = 'heat.gb18030'
|
||||||
content = b'1tDO5wo=\n'
|
content = b'1tDO5wo=\n'
|
||||||
# gb18030 has no '\0' in stream
|
# gb18030 has no '\0' in stream
|
||||||
self.assertNotIn('\0', base64.decodestring(content))
|
self.assertNotIn('\0', base64.decode_as_bytes(content))
|
||||||
decoded_content = base64.decodestring(content)
|
decoded_content = base64.decode_as_bytes(content)
|
||||||
if six.PY3:
|
if six.PY3:
|
||||||
self.assertRaises(UnicodeDecodeError, decoded_content.decode)
|
self.assertRaises(UnicodeDecodeError, decoded_content.decode)
|
||||||
else:
|
else:
|
||||||
|
Reference in New Issue
Block a user