Clean up unit tests to prepare for pylint update. (#75473)

* Fix argument name in mocked function.
* Use from import in unit tests.
* Remove unused imports.
pull/75479/head
Matt Clay 3 years ago committed by GitHub
parent ca2d2c5f38
commit 04009a77e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -47,12 +47,12 @@ class DictDataLoader(DataLoader):
# TODO: the real _get_file_contents returns a bytestring, so we actually convert the
# unicode/text it's created with to utf-8
def _get_file_contents(self, path):
path = to_text(path)
def _get_file_contents(self, file_name):
path = to_text(file_name)
if path in self._file_mapping:
return (to_bytes(self._file_mapping[path]), False)
return to_bytes(self._file_mapping[file_name]), False
else:
raise AnsibleParserError("file not found: %s" % path)
raise AnsibleParserError("file not found: %s" % file_name)
def path_exists(self, path):
path = to_text(path)

@ -5,7 +5,7 @@
from __future__ import absolute_import, division, print_function
__metaclass__ = type
import ansible.module_utils.common.warnings as warnings
from ansible.module_utils.common import warnings
from ansible.module_utils.common.arg_spec import ModuleArgumentSpecValidator, ValidationResult

@ -7,8 +7,6 @@ __metaclass__ = type
import pytest
import ansible.module_utils.common.warnings as warnings
from ansible.module_utils.common.arg_spec import ArgumentSpecValidator, ValidationResult
# Each item is id, argument_spec, parameters, expected, valid parameter names

@ -7,7 +7,7 @@ __metaclass__ = type
import pytest
import ansible.module_utils.common.warnings as warnings
from ansible.module_utils.common import warnings
from ansible.module_utils.common.warnings import deprecate, get_deprecation_messages
from ansible.module_utils.six import PY3

@ -7,7 +7,7 @@ __metaclass__ = type
import pytest
import ansible.module_utils.common.warnings as warnings
from ansible.module_utils.common import warnings
from ansible.module_utils.common.warnings import warn, get_warning_messages
from ansible.module_utils.six import PY3

@ -9,7 +9,7 @@ import base64
import os.path
import pytest
import ansible.module_utils.urls as urls
from ansible.module_utils import urls
@pytest.mark.skipif(not urls.HAS_CRYPTOGRAPHY, reason='Requires cryptography to be installed')

@ -24,9 +24,8 @@ from units.compat.mock import MagicMock, patch
from ansible import constants as C
from ansible.playbook.task import Task
from ansible.plugins.action.gather_facts import ActionModule as GatherFactsAction
from ansible.plugins import loader as plugin_loader
from ansible.template import Templar
import ansible.executor.module_common as module_common
from ansible.executor import module_common
from units.mock.loader import DictDataLoader

Loading…
Cancel
Save