summaryrefslogtreecommitdiffstats
path: root/test/units/galaxy
diff options
context:
space:
mode:
authorMatt Clay <matt@mystile.com>2023-11-02 00:28:38 +0100
committerMatt Clay <matt@mystile.com>2023-11-02 01:05:36 +0100
commit5b1b0ce7628ec1052d06f62719f36e212e962098 (patch)
treed7619250d4cd11069a1b779f48d9d8fdabb07d05 /test/units/galaxy
parentRemove Python 2.x compat from unit tests (#82109) (diff)
downloadansible-5b1b0ce7628ec1052d06f62719f36e212e962098.tar.xz
ansible-5b1b0ce7628ec1052d06f62719f36e212e962098.zip
Remove Python 2 compat (via six) from unit tests
Diffstat (limited to 'test/units/galaxy')
-rw-r--r--test/units/galaxy/test_api.py10
-rw-r--r--test/units/galaxy/test_collection.py2
-rw-r--r--test/units/galaxy/test_collection_install.py4
3 files changed, 8 insertions, 8 deletions
diff --git a/test/units/galaxy/test_api.py b/test/units/galaxy/test_api.py
index b94bbb1f25..a6c62328cc 100644
--- a/test/units/galaxy/test_api.py
+++ b/test/units/galaxy/test_api.py
@@ -23,7 +23,7 @@ from ansible.galaxy import api as galaxy_api
from ansible.galaxy.api import CollectionVersionMetadata, GalaxyAPI, GalaxyError
from ansible.galaxy.token import BasicAuthToken, GalaxyToken, KeycloakToken
from ansible.module_utils.common.text.converters import to_native, to_text
-from ansible.module_utils.six.moves.urllib import error as urllib_error
+import urllib.error
from ansible.utils import context_objects as co
from ansible.utils.display import Display
@@ -324,8 +324,8 @@ def test_initialise_automation_hub(monkeypatch):
def test_initialise_unknown(monkeypatch):
mock_open = MagicMock()
mock_open.side_effect = [
- urllib_error.HTTPError('https://galaxy.ansible.com/api/', 500, 'msg', {}, StringIO(u'{"msg":"raw error"}')),
- urllib_error.HTTPError('https://galaxy.ansible.com/api/api/', 500, 'msg', {}, StringIO(u'{"msg":"raw error"}')),
+ urllib.error.HTTPError('https://galaxy.ansible.com/api/', 500, 'msg', {}, StringIO(u'{"msg":"raw error"}')),
+ urllib.error.HTTPError('https://galaxy.ansible.com/api/api/', 500, 'msg', {}, StringIO(u'{"msg":"raw error"}')),
]
monkeypatch.setattr(galaxy_api, 'open_url', mock_open)
@@ -442,7 +442,7 @@ def test_publish_failure(api_version, collection_url, response, expected, collec
expected_url = '%s/api/%s/%s' % (api.api_server, api_version, collection_url)
mock_open = MagicMock()
- mock_open.side_effect = urllib_error.HTTPError(expected_url, 500, 'msg', {},
+ mock_open.side_effect = urllib.error.HTTPError(expected_url, 500, 'msg', {},
StringIO(to_text(json.dumps(response))))
monkeypatch.setattr(galaxy_api, 'open_url', mock_open)
@@ -1234,7 +1234,7 @@ def test_cache_flaky_pagination(cache_dir, monkeypatch):
side_effect=[
StringIO(to_text(json.dumps(responses[0]))),
StringIO(to_text(json.dumps(responses[1]))),
- urllib_error.HTTPError(responses[1]['next'], 500, 'Error', {}, StringIO()),
+ urllib.error.HTTPError(responses[1]['next'], 500, 'Error', {}, StringIO()),
StringIO(to_text(json.dumps(responses[3]))),
]
)
diff --git a/test/units/galaxy/test_collection.py b/test/units/galaxy/test_collection.py
index 3030d7b701..8dc109fffc 100644
--- a/test/units/galaxy/test_collection.py
+++ b/test/units/galaxy/test_collection.py
@@ -23,7 +23,7 @@ from ansible.cli.galaxy import GalaxyCLI
from ansible.errors import AnsibleError
from ansible.galaxy import api, collection, token
from ansible.module_utils.common.text.converters import to_bytes, to_native, to_text
-from ansible.module_utils.six.moves import builtins
+import builtins
from ansible.utils import context_objects as co
from ansible.utils.display import Display
from ansible.utils.hashing import secure_hash_s
diff --git a/test/units/galaxy/test_collection_install.py b/test/units/galaxy/test_collection_install.py
index 9ab0f1a94b..1a126d6a79 100644
--- a/test/units/galaxy/test_collection_install.py
+++ b/test/units/galaxy/test_collection_install.py
@@ -17,7 +17,7 @@ import yaml
from io import BytesIO, StringIO
from unittest.mock import MagicMock, patch
-import ansible.module_utils.six.moves.urllib.error as urllib_error
+import urllib.error
from ansible import context
from ansible.cli.galaxy import GalaxyCLI
@@ -549,7 +549,7 @@ def test_build_requirement_from_name_missing(galaxy_server, monkeypatch, tmp_pat
def test_build_requirement_from_name_401_unauthorized(galaxy_server, monkeypatch, tmp_path_factory):
mock_open = MagicMock()
- mock_open.side_effect = api.GalaxyError(urllib_error.HTTPError('https://galaxy.server.com', 401, 'msg', {},
+ mock_open.side_effect = api.GalaxyError(urllib.error.HTTPError('https://galaxy.server.com', 401, 'msg', {},
StringIO()), "error")
monkeypatch.setattr(galaxy_server, 'get_collection_versions', mock_open)