unit tests: remove unused imports (#59636)

This commit is contained in:
Andrey Klychkov 2019-07-26 17:53:31 +03:00 committed by Sam Doran
parent 65013c4001
commit 4e8df9a4b8
16 changed files with 8 additions and 27 deletions

View file

@ -31,13 +31,12 @@ import yaml
import ansible.constants as C import ansible.constants as C
from ansible import context from ansible import context
from ansible.cli.arguments import option_helpers as opt_help
from ansible.cli.galaxy import GalaxyCLI from ansible.cli.galaxy import GalaxyCLI
from ansible.errors import AnsibleError from ansible.errors import AnsibleError
from ansible.module_utils._text import to_text from ansible.module_utils._text import to_text
from ansible.utils import context_objects as co from ansible.utils import context_objects as co
from units.compat import unittest from units.compat import unittest
from units.compat.mock import call, patch, MagicMock from units.compat.mock import patch, MagicMock
@pytest.fixture(autouse='function') @pytest.fixture(autouse='function')

View file

@ -22,10 +22,8 @@ __metaclass__ = type
from units.compat import unittest from units.compat import unittest
from units.compat.mock import patch, MagicMock from units.compat.mock import patch, MagicMock
from ansible.errors import AnsibleError, AnsibleParserError
from ansible.executor.play_iterator import HostState, PlayIterator from ansible.executor.play_iterator import HostState, PlayIterator
from ansible.playbook import Playbook from ansible.playbook import Playbook
from ansible.playbook.task import Task
from ansible.playbook.play_context import PlayContext from ansible.playbook.play_context import PlayContext
from units.mock.loader import DictDataLoader from units.mock.loader import DictDataLoader

View file

@ -21,9 +21,8 @@ __metaclass__ = type
from units.compat import unittest from units.compat import unittest
from units.compat.mock import patch, MagicMock from units.compat.mock import patch, MagicMock
from ansible.errors import AnsibleError, AnsibleParserError from ansible.errors import AnsibleError
from ansible.executor.task_executor import TaskExecutor, remove_omit from ansible.executor.task_executor import TaskExecutor, remove_omit
from ansible.playbook.play_context import PlayContext
from ansible.plugins.loader import action_loader, lookup_loader from ansible.plugins.loader import action_loader, lookup_loader
from ansible.parsing.yaml.objects import AnsibleUnicode from ansible.parsing.yaml.objects import AnsibleUnicode

View file

@ -21,7 +21,6 @@ from __future__ import (absolute_import, division, print_function)
from units.compat import unittest from units.compat import unittest
from units.compat.mock import MagicMock from units.compat.mock import MagicMock
from ansible import context
from ansible.executor.task_queue_manager import TaskQueueManager from ansible.executor.task_queue_manager import TaskQueueManager
from ansible.playbook import Playbook from ansible.playbook import Playbook
from ansible.plugins.callback import CallbackBase from ansible.plugins.callback import CallbackBase

View file

@ -12,12 +12,11 @@ import os
import pytest import pytest
from units.compat.mock import MagicMock, patch from units.compat.mock import MagicMock
from ansible.module_utils import basic from ansible.module_utils import basic
from ansible.module_utils.six import string_types, integer_types from ansible.module_utils.six import integer_types
from ansible.module_utils.six.moves import builtins from ansible.module_utils.six.moves import builtins
from units.mock.procenv import ModuleTestCase, swap_stdin_and_argv
MOCK_VALIDATOR_FAIL = MagicMock(side_effect=TypeError("bad conversion")) MOCK_VALIDATOR_FAIL = MagicMock(side_effect=TypeError("bad conversion"))
# Data is argspec, argument, expected # Data is argspec, argument, expected

View file

@ -12,7 +12,7 @@ import sys
from units.mock.procenv import ModuleTestCase from units.mock.procenv import ModuleTestCase
from units.compat import unittest from units.compat import unittest
from units.compat.mock import patch, MagicMock from units.compat.mock import patch
from ansible.module_utils.six.moves import builtins from ansible.module_utils.six.moves import builtins
realimport = builtins.__import__ realimport = builtins.__import__

View file

@ -9,8 +9,6 @@ __metaclass__ = type
import pytest import pytest
from units.mock.procenv import ModuleTestCase
from units.compat.mock import patch from units.compat.mock import patch
from ansible.module_utils.six.moves import builtins from ansible.module_utils.six.moves import builtins

View file

@ -6,7 +6,7 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
from ansible.module_utils.facts.network import fc_wwn from ansible.module_utils.facts.network import fc_wwn
from units.compat.mock import Mock, patch from units.compat.mock import Mock
# AIX lsdev # AIX lsdev

View file

@ -6,7 +6,7 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
from ansible.module_utils.facts.network import iscsi from ansible.module_utils.facts.network import iscsi
from units.compat.mock import Mock, patch from units.compat.mock import Mock
# AIX # lsattr -E -l iscsi0 # AIX # lsattr -E -l iscsi0

View file

@ -16,7 +16,6 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>. # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
import os import os
import sys
import pytest import pytest
@ -95,7 +94,7 @@ class GCPAuthTestCase(unittest.TestCase):
# of this function # of this function
module = FakeModule() module = FakeModule()
with mock.patch("ansible.module_utils.gcp.open", with mock.patch("ansible.module_utils.gcp.open",
mock.mock_open(read_data='foobar'), create=True) as m: mock.mock_open(read_data='foobar'), create=True):
# pem condition, warning is suppressed with the return_value # pem condition, warning is suppressed with the return_value
credentials_file = '/foopath/pem.pem' credentials_file = '/foopath/pem.pem'
with self.assertRaises(ValueError): with self.assertRaises(ValueError):

View file

@ -15,8 +15,6 @@
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>. # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
import os
import sys
from units.compat import mock, unittest from units.compat import mock, unittest
from ansible.module_utils.gcp import check_min_pkg_version, GCPUtils, GCPInvalidURLError from ansible.module_utils.gcp import check_min_pkg_version, GCPUtils, GCPInvalidURLError

View file

@ -20,8 +20,6 @@
from __future__ import (absolute_import, division) from __future__ import (absolute_import, division)
__metaclass__ = type __metaclass__ = type
import json
from units.compat import unittest from units.compat import unittest
from ansible.module_utils.json_utils import _filter_non_json_lines from ansible.module_utils.json_utils import _filter_non_json_lines

View file

@ -4,7 +4,6 @@
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
import sys
import copy import copy
from units.compat import unittest from units.compat import unittest

View file

@ -19,7 +19,6 @@
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
from os import path
import json import json
from mock import MagicMock, patch, call from mock import MagicMock, patch, call

View file

@ -19,7 +19,6 @@
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
from os import path
import json import json
from mock import MagicMock, patch, call from mock import MagicMock, patch, call

View file

@ -6,9 +6,6 @@
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
import json
import os.path
import pytest import pytest
from ansible.module_utils import known_hosts from ansible.module_utils import known_hosts