diff options
author | Hervé Beraud <hberaud@redhat.com> | 2019-11-20 19:37:26 +0100 |
---|---|---|
committer | Hervé Beraud <hberaud@redhat.com> | 2020-04-22 12:23:44 +0200 |
commit | 5877da06a15644086a6fc15019d94a7947a09210 (patch) | |
tree | 53b2c01c4c1bb695f7262f86a44f969264a1fd3e /heat/tests | |
parent | fccd3128715a02a9ade74095d75ba18414bf997d (diff) | |
download | heat-5877da06a15644086a6fc15019d94a7947a09210.tar.gz |
Remove six and python 2.7 full support
Six is in use to help us to keep support for python 2.7.
Since the ussuri cycle we decide to remove the python 2.7
support so we can go ahead and also remove six usage from
the python code.
Review process and help
-----------------------
Removing six introduce a lot of changes and an huge amount of modified files
To simplify reviews we decided to split changes into several patches to avoid
painful reviews and avoid mistakes.
To review this patch you can use the six documentation [1] to obtain help and
understand choices.
Additional informations
-----------------------
Changes related to 'six.b(data)' [2]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
six.b [2] encode the given datas in latin-1 in python3 so I did the same
things in this patch.
Latin-1 is equal to iso-8859-1 [3].
This encoding is the default encoding [4] of certain descriptive HTTP
headers.
I suggest to keep latin-1 for the moment and to move to another encoding
in a follow-up patch if needed to move to most powerful encoding (utf8).
HTML4 support utf8 charset and utf8 is the default charset for HTML5 [5].
Note that this commit message is autogenerated and not necesserly contains
changes related to 'six.b'
[1] https://six.readthedocs.io/
[2] https://six.readthedocs.io/#six.b
[3] https://docs.python.org/3/library/codecs.html#standard-encodings
[4] https://www.w3schools.com/charsets/ref_html_8859.asp
[5] https://www.w3schools.com/html/html_charset.asp
Patch 4 of a serie of 28 patches
Change-Id: I871c2dad10abc35790e730c7c4c5272f499b7623
Diffstat (limited to 'heat/tests')
-rw-r--r-- | heat/tests/test_urlfetch.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/heat/tests/test_urlfetch.py b/heat/tests/test_urlfetch.py index e12036381..ac3f75bd2 100644 --- a/heat/tests/test_urlfetch.py +++ b/heat/tests/test_urlfetch.py @@ -11,10 +11,13 @@ # License for the specific language governing permissions and limitations # under the License. +import io +import urllib.error +import urllib.request + from oslo_config import cfg import requests from requests import exceptions -import six from heat.common import urlfetch from heat.tests import common @@ -42,15 +45,15 @@ class UrlFetchTest(common.HeatTestCase): def test_file_scheme_supported(self): data = '{ "foo": "bar" }' url = 'file:///etc/profile' - mock_open = self.patchobject(six.moves.urllib.request, 'urlopen') - mock_open.return_value = six.moves.cStringIO(data) + mock_open = self.patchobject(urllib.request, 'urlopen') + mock_open.return_value = io.StringIO(data) self.assertEqual(data, urlfetch.get(url, allowed_schemes=['file'])) mock_open.assert_called_once_with(url) def test_file_scheme_failure(self): url = 'file:///etc/profile' - mock_open = self.patchobject(six.moves.urllib.request, 'urlopen') - mock_open.side_effect = six.moves.urllib.error.URLError('oops') + mock_open = self.patchobject(urllib.request, 'urlopen') + mock_open.side_effect = urllib.error.URLError('oops') self.assertRaises(urlfetch.URLFetchError, urlfetch.get, url, allowed_schemes=['file']) mock_open.assert_called_once_with(url) @@ -109,5 +112,5 @@ class UrlFetchTest(common.HeatTestCase): mock_get.return_value = response exception = self.assertRaises(urlfetch.URLFetchError, urlfetch.get, url) - self.assertIn("Template exceeds", six.text_type(exception)) + self.assertIn("Template exceeds", str(exception)) mock_get.assert_called_once_with(url, stream=True) |