mirror of
https://github.com/ansible-collections/community.docker.git
synced 2025-12-15 19:42:06 +00:00
Avoid Python 2 compat (conditional) imports. (#1167)
This commit is contained in:
parent
6f9ebc3f14
commit
597162b153
@ -4,15 +4,13 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import unittest
|
||||
from io import StringIO
|
||||
from unittest import mock
|
||||
|
||||
from ansible.errors import AnsibleError
|
||||
from ansible.playbook.play_context import PlayContext
|
||||
from ansible.plugins.loader import connection_loader
|
||||
from ansible_collections.community.internal_test_tools.tests.unit.compat import (
|
||||
mock,
|
||||
unittest,
|
||||
)
|
||||
|
||||
|
||||
class TestDockerConnectionClass(unittest.TestCase):
|
||||
|
||||
@ -4,13 +4,12 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from unittest.mock import create_autospec
|
||||
|
||||
import pytest
|
||||
from ansible.inventory.data import InventoryData
|
||||
from ansible.parsing.dataloader import DataLoader
|
||||
from ansible.template import Templar
|
||||
from ansible_collections.community.internal_test_tools.tests.unit.compat.mock import (
|
||||
create_autospec,
|
||||
)
|
||||
from ansible_collections.community.internal_test_tools.tests.unit.utils.trust import (
|
||||
make_trusted,
|
||||
)
|
||||
|
||||
@ -22,6 +22,7 @@ import time
|
||||
import unittest
|
||||
from http.server import BaseHTTPRequestHandler
|
||||
from socketserver import ThreadingTCPServer
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
import requests
|
||||
@ -41,12 +42,6 @@ from ansible_collections.community.docker.tests.unit.plugins.module_utils._api.c
|
||||
from .. import fake_api
|
||||
|
||||
|
||||
try:
|
||||
from unittest import mock
|
||||
except ImportError:
|
||||
import mock
|
||||
|
||||
|
||||
DEFAULT_TIMEOUT_SECONDS = constants.DEFAULT_TIMEOUT_SECONDS
|
||||
|
||||
|
||||
|
||||
@ -16,6 +16,7 @@ import random
|
||||
import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
@ -28,12 +29,6 @@ from ansible_collections.community.docker.plugins.module_utils._api.credentials.
|
||||
)
|
||||
|
||||
|
||||
try:
|
||||
from unittest import mock
|
||||
except ImportError:
|
||||
import mock
|
||||
|
||||
|
||||
class RegressionTest(unittest.TestCase):
|
||||
def test_803_urlsafe_encode(self):
|
||||
auth_data = {"username": "root", "password": "GR?XGR?XGR?XGR?X"}
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import unittest
|
||||
from ssl import OP_NO_SSLv2, OP_NO_SSLv3, OP_NO_TLSv1
|
||||
|
||||
import pytest
|
||||
|
||||
@ -24,13 +25,6 @@ except ImportError:
|
||||
else:
|
||||
HAS_MATCH_HOSTNAME = True # pylint: disable=invalid-name
|
||||
|
||||
try:
|
||||
from ssl import OP_NO_SSLv2, OP_NO_SSLv3, OP_NO_TLSv1
|
||||
except ImportError:
|
||||
OP_NO_SSLv2 = 0x1000000
|
||||
OP_NO_SSLv3 = 0x2000000
|
||||
OP_NO_TLSv1 = 0x4000000
|
||||
|
||||
|
||||
class SSLAdapterTest(unittest.TestCase):
|
||||
def test_only_uses_tls(self):
|
||||
|
||||
@ -14,18 +14,13 @@ import shutil
|
||||
import tempfile
|
||||
import typing as t
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
from pytest import fixture, mark
|
||||
|
||||
from ansible_collections.community.docker.plugins.module_utils._api.utils import config
|
||||
|
||||
|
||||
try:
|
||||
from unittest import mock
|
||||
except ImportError:
|
||||
import mock
|
||||
|
||||
|
||||
class FindConfigFileTest(unittest.TestCase):
|
||||
mkdir: t.Callable[[str], os.PathLike[str]]
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user