summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorThomas Grainger <tagrain@gmail.com>2021-07-20 14:07:49 +0100
committerGitHub <noreply@github.com>2021-07-20 19:07:49 +0600
commit241b5dcff8a7c8ad411e1b325d59e47acfa9e1ed (patch)
tree14b5c70fb2e2e2e4c53356d8a21da0540da16759 /t
parent1ce0afe39ab26487c1cdfd9d4ba8c5bb445c8f32 (diff)
downloadkombu-241b5dcff8a7c8ad411e1b325d59e47acfa9e1ed.tar.gz
enable pre-commit (#1355)
* enable pre-commit * use extend-ignore for flake8 * manual flake8 fixes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update kombu/__init__.py Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Diffstat (limited to 't')
-rw-r--r--t/integration/common.py1
-rw-r--r--t/integration/test_py_amqp.py7
-rw-r--r--t/integration/test_redis.py7
-rw-r--r--t/mocks.py2
-rw-r--r--t/skip.py1
-rw-r--r--t/unit/asynchronous/aws/sqs/test_connection.py7
-rw-r--r--t/unit/asynchronous/aws/sqs/test_queue.py5
-rw-r--r--t/unit/asynchronous/aws/test_connection.py26
-rw-r--r--t/unit/asynchronous/http/test_curl.py5
-rw-r--r--t/unit/asynchronous/http/test_http.py9
-rw-r--r--t/unit/asynchronous/test_hub.py14
-rw-r--r--t/unit/asynchronous/test_timer.py5
-rw-r--r--t/unit/conftest.py3
-rw-r--r--t/unit/test_clocks.py2
-rw-r--r--t/unit/test_common.py14
-rw-r--r--t/unit/test_compat.py8
-rw-r--r--t/unit/test_connection.py6
-rw-r--r--t/unit/test_entity.py5
-rw-r--r--t/unit/test_log.py11
-rw-r--r--t/unit/test_matcher.py8
-rw-r--r--t/unit/test_message.py4
-rw-r--r--t/unit/test_messaging.py8
-rw-r--r--t/unit/test_mixins.py4
-rw-r--r--t/unit/test_pidbox.py7
-rw-r--r--t/unit/test_pools.py7
-rw-r--r--t/unit/test_serialization.py24
-rw-r--r--t/unit/test_simple.py4
-rw-r--r--t/unit/transport/test_SQS.py17
-rw-r--r--t/unit/transport/test_azureservicebus.py25
-rw-r--r--t/unit/transport/test_base.py9
-rw-r--r--t/unit/transport/test_consul.py5
-rw-r--r--t/unit/transport/test_etcd.py5
-rw-r--r--t/unit/transport/test_filesystem.py4
-rw-r--r--t/unit/transport/test_librabbitmq.py4
-rw-r--r--t/unit/transport/test_memory.py5
-rw-r--r--t/unit/transport/test_mongodb.py7
-rw-r--r--t/unit/transport/test_pyamqp.py3
-rw-r--r--t/unit/transport/test_pyro.py5
-rw-r--r--t/unit/transport/test_qpid.py12
-rw-r--r--t/unit/transport/test_redis.py11
-rw-r--r--t/unit/transport/test_sqlalchemy.py4
-rw-r--r--t/unit/transport/test_zookeeper.py1
-rw-r--r--t/unit/transport/virtual/test_base.py8
-rw-r--r--t/unit/transport/virtual/test_exchange.py5
-rw-r--r--t/unit/utils/test_amq_manager.py4
-rw-r--r--t/unit/utils/test_compat.py2
-rw-r--r--t/unit/utils/test_debug.py1
-rw-r--r--t/unit/utils/test_div.py3
-rw-r--r--t/unit/utils/test_encoding.py8
-rw-r--r--t/unit/utils/test_functional.py15
-rw-r--r--t/unit/utils/test_imports.py4
-rw-r--r--t/unit/utils/test_json.py7
-rw-r--r--t/unit/utils/test_objects.py4
-rw-r--r--t/unit/utils/test_scheduling.py4
-rw-r--r--t/unit/utils/test_url.py4
55 files changed, 166 insertions, 224 deletions
diff --git a/t/integration/common.py b/t/integration/common.py
index a749bb60..5d3d6382 100644
--- a/t/integration/common.py
+++ b/t/integration/common.py
@@ -3,6 +3,7 @@ from contextlib import closing
from time import sleep
import pytest
+
import kombu
diff --git a/t/integration/test_py_amqp.py b/t/integration/test_py_amqp.py
index da21be40..88ff0ac7 100644
--- a/t/integration/test_py_amqp.py
+++ b/t/integration/test_py_amqp.py
@@ -1,12 +1,11 @@
import os
import pytest
+
import kombu
-from .common import (
- BasicFunctionality, BaseExchangeTypes,
- BaseTimeToLive, BasePriority, BaseFailover
-)
+from .common import (BaseExchangeTypes, BaseFailover, BasePriority,
+ BaseTimeToLive, BasicFunctionality)
def get_connection(hostname, port, vhost):
diff --git a/t/integration/test_redis.py b/t/integration/test_redis.py
index 459f0892..82eeceb2 100644
--- a/t/integration/test_redis.py
+++ b/t/integration/test_redis.py
@@ -1,12 +1,11 @@
import os
+from time import sleep
import pytest
+
import kombu
-from time import sleep
-from .common import (
- BasicFunctionality, BaseExchangeTypes, BasePriority
-)
+from .common import BaseExchangeTypes, BasePriority, BasicFunctionality
def get_connection(
diff --git a/t/mocks.py b/t/mocks.py
index c515ed5d..d1bccf39 100644
--- a/t/mocks.py
+++ b/t/mocks.py
@@ -1,6 +1,6 @@
from itertools import count
-
from unittest.mock import Mock
+
from case import ContextMock
from kombu.transport import base
diff --git a/t/skip.py b/t/skip.py
index 487d80c8..d2c59caa 100644
--- a/t/skip.py
+++ b/t/skip.py
@@ -1,4 +1,5 @@
import sys
+
import pytest
if_pypy = pytest.mark.skipif(
diff --git a/t/unit/asynchronous/aws/sqs/test_connection.py b/t/unit/asynchronous/aws/sqs/test_connection.py
index 7623a6d1..c3dd184b 100644
--- a/t/unit/asynchronous/aws/sqs/test_connection.py
+++ b/t/unit/asynchronous/aws/sqs/test_connection.py
@@ -1,13 +1,10 @@
-from unittest.mock import Mock, MagicMock
+from unittest.mock import MagicMock, Mock
-from kombu.asynchronous.aws.sqs.connection import (
- AsyncSQSConnection
-)
from kombu.asynchronous.aws.ext import boto3
+from kombu.asynchronous.aws.sqs.connection import AsyncSQSConnection
from kombu.asynchronous.aws.sqs.message import AsyncMessage
from kombu.asynchronous.aws.sqs.queue import AsyncQueue
from kombu.utils.uuid import uuid
-
from t.mocks import PromiseMock
from ..case import AWSCase
diff --git a/t/unit/asynchronous/aws/sqs/test_queue.py b/t/unit/asynchronous/aws/sqs/test_queue.py
index e4ad1c6a..56812831 100644
--- a/t/unit/asynchronous/aws/sqs/test_queue.py
+++ b/t/unit/asynchronous/aws/sqs/test_queue.py
@@ -1,10 +1,9 @@
-import pytest
-
from unittest.mock import Mock
+import pytest
+
from kombu.asynchronous.aws.sqs.message import AsyncMessage
from kombu.asynchronous.aws.sqs.queue import AsyncQueue
-
from t.mocks import PromiseMock
from ..case import AWSCase
diff --git a/t/unit/asynchronous/aws/test_connection.py b/t/unit/asynchronous/aws/test_connection.py
index 78cbe522..68e3c746 100644
--- a/t/unit/asynchronous/aws/test_connection.py
+++ b/t/unit/asynchronous/aws/test_connection.py
@@ -1,31 +1,25 @@
+from contextlib import contextmanager
from io import StringIO
+from unittest.mock import Mock
import pytest
-
-from contextlib import contextmanager
-
-from unittest.mock import Mock
from vine.abstract import Thenable
-from kombu.exceptions import HttpError
-
from kombu.asynchronous import http
-from kombu.asynchronous.aws.connection import (
- AsyncHTTPSConnection,
- AsyncHTTPResponse,
- AsyncConnection,
- AsyncAWSQueryConnection,
-)
+from kombu.asynchronous.aws.connection import (AsyncAWSQueryConnection,
+ AsyncConnection,
+ AsyncHTTPResponse,
+ AsyncHTTPSConnection)
from kombu.asynchronous.aws.ext import boto3
+from kombu.exceptions import HttpError
+from t.mocks import PromiseMock
from .case import AWSCase
-from t.mocks import PromiseMock
-
try:
- from urllib.parse import urlparse, parse_qs
+ from urllib.parse import parse_qs, urlparse
except ImportError:
- from urlparse import urlparse, parse_qs # noqa
+ from urlparse import parse_qs, urlparse
# Not currently working
VALIDATES_CERT = False
diff --git a/t/unit/asynchronous/http/test_curl.py b/t/unit/asynchronous/http/test_curl.py
index 7c62808a..db8f5f91 100644
--- a/t/unit/asynchronous/http/test_curl.py
+++ b/t/unit/asynchronous/http/test_curl.py
@@ -1,10 +1,9 @@
-import pytest
-
from unittest.mock import Mock, call, patch
-from kombu.asynchronous.http.curl import READ, WRITE, CurlClient
+import pytest
import t.skip
+from kombu.asynchronous.http.curl import READ, WRITE, CurlClient
pytest.importorskip('pycurl')
diff --git a/t/unit/asynchronous/http/test_http.py b/t/unit/asynchronous/http/test_http.py
index 110433fc..6e6abdcb 100644
--- a/t/unit/asynchronous/http/test_http.py
+++ b/t/unit/asynchronous/http/test_http.py
@@ -1,17 +1,14 @@
-import pytest
-
from io import BytesIO
+from unittest.mock import Mock
+import pytest
from vine import promise
-from unittest.mock import Mock
-
+import t.skip
from kombu.asynchronous import http
from kombu.asynchronous.http.base import BaseClient, normalize_header
from kombu.exceptions import HttpError
-
from t.mocks import PromiseMock
-import t.skip
class test_Headers:
diff --git a/t/unit/asynchronous/test_hub.py b/t/unit/asynchronous/test_hub.py
index 31f21124..eae25357 100644
--- a/t/unit/asynchronous/test_hub.py
+++ b/t/unit/asynchronous/test_hub.py
@@ -1,16 +1,14 @@
import errno
-import pytest
-
from unittest.mock import Mock, call, patch
+
+import pytest
from vine import promise
+from kombu.asynchronous import ERR, READ, WRITE, Hub
from kombu.asynchronous import hub as _hub
-from kombu.asynchronous import Hub, READ, WRITE, ERR
-from kombu.asynchronous.debug import callback_for, repr_flag, _rcb
-from kombu.asynchronous.hub import (
- Stop, get_event_loop, set_event_loop,
- _raise_stop_error, _dummy_context
-)
+from kombu.asynchronous.debug import _rcb, callback_for, repr_flag
+from kombu.asynchronous.hub import (Stop, _dummy_context, _raise_stop_error,
+ get_event_loop, set_event_loop)
from kombu.asynchronous.semaphore import DummyLock, LaxBoundedSemaphore
diff --git a/t/unit/asynchronous/test_timer.py b/t/unit/asynchronous/test_timer.py
index a521d368..20411784 100644
--- a/t/unit/asynchronous/test_timer.py
+++ b/t/unit/asynchronous/test_timer.py
@@ -1,9 +1,8 @@
-import pytest
-
from datetime import datetime
-
from unittest.mock import Mock, patch
+import pytest
+
from kombu.asynchronous.timer import Entry, Timer, to_timestamp
diff --git a/t/unit/conftest.py b/t/unit/conftest.py
index 638fa9aa..d9cc0244 100644
--- a/t/unit/conftest.py
+++ b/t/unit/conftest.py
@@ -1,8 +1,9 @@
import atexit
import os
-import pytest
import sys
+import pytest
+
from kombu.exceptions import VersionMismatch
diff --git a/t/unit/test_clocks.py b/t/unit/test_clocks.py
index c8d52bec..b4392440 100644
--- a/t/unit/test_clocks.py
+++ b/t/unit/test_clocks.py
@@ -1,8 +1,6 @@
import pickle
-
from heapq import heappush
from time import time
-
from unittest.mock import Mock
from kombu.clocks import LamportClock, timetuple
diff --git a/t/unit/test_common.py b/t/unit/test_common.py
index 4f560b67..33e2571f 100644
--- a/t/unit/test_common.py
+++ b/t/unit/test_common.py
@@ -1,18 +1,14 @@
-import pytest
import socket
+from unittest.mock import Mock, patch
+import pytest
from amqp import RecoverableConnectionError
-from unittest.mock import Mock, patch
from case import ContextMock
from kombu import common
-from kombu.common import (
- Broadcast, maybe_declare,
- send_reply, collect_replies,
- declaration_cached, ignore_errors,
- QoS, PREFETCH_COUNT_MAX, generate_oid
-)
-
+from kombu.common import (PREFETCH_COUNT_MAX, Broadcast, QoS, collect_replies,
+ declaration_cached, generate_oid, ignore_errors,
+ maybe_declare, send_reply)
from t.mocks import MockPool
diff --git a/t/unit/test_compat.py b/t/unit/test_compat.py
index a4ff98b2..d75ce5df 100644
--- a/t/unit/test_compat.py
+++ b/t/unit/test_compat.py
@@ -1,11 +1,9 @@
-import pytest
-
from unittest.mock import Mock, patch
-from kombu import Connection, Exchange, Queue
-from kombu import compat
+import pytest
-from t.mocks import Transport, Channel
+from kombu import Connection, Exchange, Queue, compat
+from t.mocks import Channel, Transport
class test_misc:
diff --git a/t/unit/test_connection.py b/t/unit/test_connection.py
index 32c46dd2..0b184d3b 100644
--- a/t/unit/test_connection.py
+++ b/t/unit/test_connection.py
@@ -1,16 +1,14 @@
import pickle
-import pytest
import socket
-
from copy import copy, deepcopy
-
from unittest.mock import Mock, patch
+import pytest
+
from kombu import Connection, Consumer, Producer, parse_url
from kombu.connection import Resource
from kombu.exceptions import OperationalError
from kombu.utils.functional import lazy
-
from t.mocks import Transport
diff --git a/t/unit/test_entity.py b/t/unit/test_entity.py
index 3ba36bef..52c42b2b 100644
--- a/t/unit/test_entity.py
+++ b/t/unit/test_entity.py
@@ -1,13 +1,12 @@
import pickle
-import pytest
-
from unittest.mock import Mock, call
+import pytest
+
from kombu import Connection, Exchange, Producer, Queue, binding
from kombu.abstract import MaybeChannelBound
from kombu.exceptions import NotBoundError
from kombu.serialization import registry
-
from t.mocks import Transport
diff --git a/t/unit/test_log.py b/t/unit/test_log.py
index bd3cb636..4a8cd94c 100644
--- a/t/unit/test_log.py
+++ b/t/unit/test_log.py
@@ -1,16 +1,9 @@
import logging
import sys
-
from unittest.mock import ANY, Mock, patch
-from kombu.log import (
- get_logger,
- get_loglevel,
- safeify_format,
- Log,
- LogMixin,
- setup_logging,
-)
+from kombu.log import (Log, LogMixin, get_logger, get_loglevel, safeify_format,
+ setup_logging)
class test_get_logger:
diff --git a/t/unit/test_matcher.py b/t/unit/test_matcher.py
index 0428ee15..2100fa74 100644
--- a/t/unit/test_matcher.py
+++ b/t/unit/test_matcher.py
@@ -1,10 +1,8 @@
-from kombu.matcher import (
- match, register, registry, unregister, fnmatch, rematch,
- MatcherNotInstalled
-)
-
import pytest
+from kombu.matcher import (MatcherNotInstalled, fnmatch, match, register,
+ registry, rematch, unregister)
+
class test_Matcher:
diff --git a/t/unit/test_message.py b/t/unit/test_message.py
index a0be3a46..5b0833dd 100644
--- a/t/unit/test_message.py
+++ b/t/unit/test_message.py
@@ -1,8 +1,8 @@
-import pytest
import sys
-
from unittest.mock import Mock, patch
+import pytest
+
from kombu.message import Message
diff --git a/t/unit/test_messaging.py b/t/unit/test_messaging.py
index dc673e07..f8ed437c 100644
--- a/t/unit/test_messaging.py
+++ b/t/unit/test_messaging.py
@@ -1,16 +1,14 @@
import pickle
-import pytest
import sys
-
from collections import defaultdict
-
from unittest.mock import Mock, patch
-from kombu import Connection, Consumer, Producer, Exchange, Queue
+import pytest
+
+from kombu import Connection, Consumer, Exchange, Producer, Queue
from kombu.exceptions import MessageStateError
from kombu.utils import json
from kombu.utils.functional import ChannelPromise
-
from t.mocks import Transport
diff --git a/t/unit/test_mixins.py b/t/unit/test_mixins.py
index 12647bf1..a86c3978 100644
--- a/t/unit/test_mixins.py
+++ b/t/unit/test_mixins.py
@@ -1,7 +1,7 @@
-import pytest
import socket
-
from unittest.mock import Mock, patch
+
+import pytest
from case import ContextMock
from kombu.mixins import ConsumerMixin
diff --git a/t/unit/test_pidbox.py b/t/unit/test_pidbox.py
index dc2467cb..7a1b9b1f 100644
--- a/t/unit/test_pidbox.py
+++ b/t/unit/test_pidbox.py
@@ -1,11 +1,10 @@
-import pytest
import socket
import warnings
-
from unittest.mock import Mock, patch
-from kombu import Connection
-from kombu import pidbox
+import pytest
+
+from kombu import Connection, pidbox
from kombu.exceptions import ContentDisallowed, InconsistencyError
from kombu.utils.uuid import uuid
diff --git a/t/unit/test_pools.py b/t/unit/test_pools.py
index 2857914e..9f33f4b8 100644
--- a/t/unit/test_pools.py
+++ b/t/unit/test_pools.py
@@ -1,9 +1,8 @@
-import pytest
-
from unittest.mock import Mock
-from kombu import Connection, Producer
-from kombu import pools
+import pytest
+
+from kombu import Connection, Producer, pools
from kombu.connection import ConnectionPool
from kombu.utils.collections import eqhash
diff --git a/t/unit/test_serialization.py b/t/unit/test_serialization.py
index fe5ea625..29c9d809 100644
--- a/t/unit/test_serialization.py
+++ b/t/unit/test_serialization.py
@@ -1,23 +1,21 @@
#!/usr/bin/python
-import pytest
-
from base64 import b64decode
-
from unittest.mock import call, patch
-from case import mock
-from kombu.exceptions import ContentDisallowed, EncodeError, DecodeError
-from kombu.serialization import (
- registry, register, SerializerNotInstalled,
- raw_encode, register_yaml, register_msgpack,
- dumps, loads, pickle, pickle_protocol,
- unregister, register_pickle, enable_insecure_serializers,
- disable_insecure_serializers, prepare_accept_content
-)
-from kombu.utils.encoding import str_to_bytes
+import pytest
+from case import mock
import t.skip
+from kombu.exceptions import ContentDisallowed, DecodeError, EncodeError
+from kombu.serialization import (SerializerNotInstalled,
+ disable_insecure_serializers, dumps,
+ enable_insecure_serializers, loads, pickle,
+ pickle_protocol, prepare_accept_content,
+ raw_encode, register, register_msgpack,
+ register_pickle, register_yaml, registry,
+ unregister)
+from kombu.utils.encoding import str_to_bytes
# For content_encoding tests
unicode_string = 'abcdé\u8463'
diff --git a/t/unit/test_simple.py b/t/unit/test_simple.py
index c4badb03..a5cd899a 100644
--- a/t/unit/test_simple.py
+++ b/t/unit/test_simple.py
@@ -1,7 +1,7 @@
-import pytest
-
from unittest.mock import Mock
+import pytest
+
from kombu import Connection, Exchange, Queue
from kombu.exceptions import ContentDisallowed
diff --git a/t/unit/transport/test_SQS.py b/t/unit/transport/test_SQS.py
index 5d958c8b..9a105837 100644
--- a/t/unit/transport/test_SQS.py
+++ b/t/unit/transport/test_SQS.py
@@ -6,22 +6,21 @@ slightly.
"""
import base64
import os
-from datetime import datetime, timedelta
-
-import pytest
import random
import string
+from datetime import datetime, timedelta
from queue import Empty
-
from unittest.mock import Mock, patch
-from kombu import messaging
-from kombu import Connection, Exchange, Queue
+import pytest
+
+from kombu import Connection, Exchange, Queue, messaging
boto3 = pytest.importorskip('boto3')
-from kombu.transport import SQS # noqa
-from botocore.exceptions import ClientError # noqa
+from botocore.exceptions import ClientError # noqa
+
+from kombu.transport import SQS # noqa
SQS_Channel_sqs = SQS.Channel.sqs
@@ -63,7 +62,7 @@ class QueueMock:
self.messages = []
def __repr__(self):
- return 'QueueMock: {} {} messages'.format(self.url, len(self.messages))
+ return f'QueueMock: {self.url} {len(self.messages)} messages'
class SQSClientMock:
diff --git a/t/unit/transport/test_azureservicebus.py b/t/unit/transport/test_azureservicebus.py
index 47cc9fd5..97775d06 100644
--- a/t/unit/transport/test_azureservicebus.py
+++ b/t/unit/transport/test_azureservicebus.py
@@ -1,19 +1,20 @@
-import json
-import pytest
import base64
+import json
import random
+from collections import namedtuple
from queue import Empty
+from unittest.mock import MagicMock, patch
-from unittest.mock import patch, MagicMock
-from collections import namedtuple
-from kombu import messaging
-from kombu import Connection, Exchange, Queue
+import pytest
+
+from kombu import Connection, Exchange, Queue, messaging
pytest.importorskip('azure.servicebus')
-from kombu.transport import azureservicebus # noqa
-import azure.servicebus.exceptions # noqa
-import azure.core.exceptions # noqa
-from azure.servicebus import ServiceBusMessage, ServiceBusReceiveMode # noqa
+import azure.core.exceptions # noqa
+import azure.servicebus.exceptions # noqa
+from azure.servicebus import ServiceBusMessage, ServiceBusReceiveMode # noqa
+
+from kombu.transport import azureservicebus # noqa
class ASBQueue:
@@ -181,7 +182,7 @@ def test_invalid_peek_lock_seconds():
@pytest.fixture
def random_queue():
- return 'azureservicebus_queue_{0}'.format(random.randint(1000, 9999))
+ return f'azureservicebus_queue_{random.randint(1000, 9999)}'
@pytest.fixture
@@ -255,7 +256,7 @@ def test_empty_queue_get(mock_queue: MockQueue):
def test_delete_empty_queue(mock_queue: MockQueue):
chan = mock_queue.channel
- queue_name = 'random_queue_{0}'.format(random.randint(1000, 9999))
+ queue_name = f'random_queue_{random.randint(1000, 9999)}'
chan._new_queue(queue_name)
assert queue_name in chan._queue_cache
diff --git a/t/unit/transport/test_base.py b/t/unit/transport/test_base.py
index e122b1e2..7df12c9e 100644
--- a/t/unit/transport/test_base.py
+++ b/t/unit/transport/test_base.py
@@ -1,12 +1,11 @@
-import pytest
-
from unittest.mock import Mock
+import pytest
+
from kombu import Connection, Consumer, Exchange, Producer, Queue
from kombu.message import Message
-from kombu.transport.base import (
- StdChannel, Transport, Management, to_rabbitmq_queue_arguments,
-)
+from kombu.transport.base import (Management, StdChannel, Transport,
+ to_rabbitmq_queue_arguments)
@pytest.mark.parametrize('args,input,expected', [
diff --git a/t/unit/transport/test_consul.py b/t/unit/transport/test_consul.py
index 0ae02fa8..ce6c4fcb 100644
--- a/t/unit/transport/test_consul.py
+++ b/t/unit/transport/test_consul.py
@@ -1,9 +1,8 @@
-import pytest
-
from queue import Empty
-
from unittest.mock import Mock
+import pytest
+
from kombu.transport.consul import Channel, Transport
pytest.importorskip('consul')
diff --git a/t/unit/transport/test_etcd.py b/t/unit/transport/test_etcd.py
index fb4eeec5..6c75a033 100644
--- a/t/unit/transport/test_etcd.py
+++ b/t/unit/transport/test_etcd.py
@@ -1,9 +1,8 @@
-import pytest
-
from queue import Empty
-
from unittest.mock import Mock, patch
+import pytest
+
from kombu.transport.etcd import Channel, Transport
pytest.importorskip('etcd')
diff --git a/t/unit/transport/test_filesystem.py b/t/unit/transport/test_filesystem.py
index 0702ad3c..a8d1708b 100644
--- a/t/unit/transport/test_filesystem.py
+++ b/t/unit/transport/test_filesystem.py
@@ -1,9 +1,9 @@
import tempfile
import pytest
-import t.skip
-from kombu import Connection, Exchange, Queue, Consumer, Producer
+import t.skip
+from kombu import Connection, Consumer, Exchange, Producer, Queue
@t.skip.if_win32
diff --git a/t/unit/transport/test_librabbitmq.py b/t/unit/transport/test_librabbitmq.py
index e409c76b..58ee7e1e 100644
--- a/t/unit/transport/test_librabbitmq.py
+++ b/t/unit/transport/test_librabbitmq.py
@@ -1,7 +1,7 @@
-import pytest
-
from unittest.mock import Mock, patch
+import pytest
+
pytest.importorskip('librabbitmq')
from kombu.transport import librabbitmq # noqa
diff --git a/t/unit/transport/test_memory.py b/t/unit/transport/test_memory.py
index 6db08827..2c1fe83f 100644
--- a/t/unit/transport/test_memory.py
+++ b/t/unit/transport/test_memory.py
@@ -1,7 +1,8 @@
-import pytest
import socket
-from kombu import Connection, Exchange, Queue, Consumer, Producer
+import pytest
+
+from kombu import Connection, Consumer, Exchange, Producer, Queue
class test_MemoryTransport:
diff --git a/t/unit/transport/test_mongodb.py b/t/unit/transport/test_mongodb.py
index eaba3769..39976988 100644
--- a/t/unit/transport/test_mongodb.py
+++ b/t/unit/transport/test_mongodb.py
@@ -1,17 +1,16 @@
import datetime
-import pytest
-
from queue import Empty
-
from unittest.mock import MagicMock, call, patch
+import pytest
+
from kombu import Connection
pymongo = pytest.importorskip('pymongo')
def _create_mock_connection(url='', **kwargs):
- from kombu.transport import mongodb # noqa
+ from kombu.transport import mongodb
class _Channel(mongodb.Channel):
# reset _fanout_queues for each instance
diff --git a/t/unit/transport/test_pyamqp.py b/t/unit/transport/test_pyamqp.py
index 3ca9a83f..c7243e8e 100644
--- a/t/unit/transport/test_pyamqp.py
+++ b/t/unit/transport/test_pyamqp.py
@@ -1,8 +1,7 @@
import sys
-
from itertools import count
-
from unittest.mock import Mock, patch
+
from case import mock
from kombu import Connection
diff --git a/t/unit/transport/test_pyro.py b/t/unit/transport/test_pyro.py
index a7d27324..325f81ce 100644
--- a/t/unit/transport/test_pyro.py
+++ b/t/unit/transport/test_pyro.py
@@ -1,7 +1,8 @@
-import pytest
import socket
-from kombu import Connection, Exchange, Queue, Consumer, Producer
+import pytest
+
+from kombu import Connection, Consumer, Exchange, Producer, Queue
class test_PyroTransport:
diff --git a/t/unit/transport/test_qpid.py b/t/unit/transport/test_qpid.py
index dba2f514..351a929b 100644
--- a/t/unit/transport/test_qpid.py
+++ b/t/unit/transport/test_qpid.py
@@ -1,26 +1,22 @@
-import pytest
import select
-import ssl
import socket
+import ssl
import sys
import time
import uuid
-from queue import Empty
-
from collections import OrderedDict
-
from collections.abc import Callable
-
from itertools import count
-
+from queue import Empty
from unittest.mock import Mock, call, patch
+import pytest
+
from kombu.transport.qpid import (AuthenticationFailure, Channel, Connection,
ConnectionError, Message, NotFound, QoS,
Transport)
from kombu.transport.virtual import Base64
-
QPID_MODULE = 'kombu.transport.qpid'
diff --git a/t/unit/transport/test_redis.py b/t/unit/transport/test_redis.py
index 5b1ed971..52ea7f81 100644
--- a/t/unit/transport/test_redis.py
+++ b/t/unit/transport/test_redis.py
@@ -1,15 +1,15 @@
-import pytest
-
import socket
import types
-
from collections import defaultdict
from itertools import count
-from queue import Empty, Queue as _Queue
+from queue import Empty
+from queue import Queue as _Queue
from unittest.mock import ANY, Mock, call, patch
+
+import pytest
from case import ContextMock, mock
-from kombu import Connection, Exchange, Queue, Consumer, Producer
+from kombu import Connection, Consumer, Exchange, Producer, Queue
from kombu.exceptions import InconsistencyError, VersionMismatch
from kombu.transport import virtual
from kombu.utils import eventio # patch poll
@@ -314,6 +314,7 @@ class test_Channel:
def test_get_redis_ConnectionError(self):
from redis.exceptions import ConnectionError
+
from kombu.transport.redis import get_redis_ConnectionError
connection_error = get_redis_ConnectionError()
assert connection_error == ConnectionError
diff --git a/t/unit/transport/test_sqlalchemy.py b/t/unit/transport/test_sqlalchemy.py
index c988cf33..5ddca5ac 100644
--- a/t/unit/transport/test_sqlalchemy.py
+++ b/t/unit/transport/test_sqlalchemy.py
@@ -1,8 +1,8 @@
-import pytest
from unittest.mock import patch
-from kombu import Connection
+import pytest
+from kombu import Connection
pytest.importorskip('sqlalchemy')
diff --git a/t/unit/transport/test_zookeeper.py b/t/unit/transport/test_zookeeper.py
index 6650f03c..21fcac42 100644
--- a/t/unit/transport/test_zookeeper.py
+++ b/t/unit/transport/test_zookeeper.py
@@ -1,4 +1,5 @@
import pytest
+
from kombu import Connection
from kombu.transport import zookeeper
diff --git a/t/unit/transport/virtual/test_base.py b/t/unit/transport/virtual/test_base.py
index 08ae0a84..1a079a36 100644
--- a/t/unit/transport/virtual/test_base.py
+++ b/t/unit/transport/virtual/test_base.py
@@ -1,14 +1,14 @@
import io
-import pytest
-import warnings
import socket
+import warnings
from time import monotonic
-
from unittest.mock import MagicMock, Mock, patch
+import pytest
+
from kombu import Connection
from kombu.compression import compress
-from kombu.exceptions import ResourceError, ChannelError
+from kombu.exceptions import ChannelError, ResourceError
from kombu.transport import virtual
from kombu.utils.uuid import uuid
diff --git a/t/unit/transport/virtual/test_exchange.py b/t/unit/transport/virtual/test_exchange.py
index 8ae2bb5a..ac0a8b68 100644
--- a/t/unit/transport/virtual/test_exchange.py
+++ b/t/unit/transport/virtual/test_exchange.py
@@ -1,10 +1,9 @@
-import pytest
-
from unittest.mock import Mock
+import pytest
+
from kombu import Connection
from kombu.transport.virtual import exchange
-
from t.mocks import Transport
diff --git a/t/unit/utils/test_amq_manager.py b/t/unit/utils/test_amq_manager.py
index 663e922e..aa3d7574 100644
--- a/t/unit/utils/test_amq_manager.py
+++ b/t/unit/utils/test_amq_manager.py
@@ -1,6 +1,6 @@
-import pytest
-
from unittest.mock import patch
+
+import pytest
from case import mock
from kombu import Connection
diff --git a/t/unit/utils/test_compat.py b/t/unit/utils/test_compat.py
index ce0c0cc8..a0bf18b0 100644
--- a/t/unit/utils/test_compat.py
+++ b/t/unit/utils/test_compat.py
@@ -1,8 +1,8 @@
import socket
import sys
import types
-
from unittest.mock import Mock, patch
+
from case import mock
from kombu.utils import compat
diff --git a/t/unit/utils/test_debug.py b/t/unit/utils/test_debug.py
index ca3cad8c..020bc849 100644
--- a/t/unit/utils/test_debug.py
+++ b/t/unit/utils/test_debug.py
@@ -1,5 +1,4 @@
import logging
-
from unittest.mock import Mock, patch
from kombu.utils.debug import Logwrapped, setup_logging
diff --git a/t/unit/utils/test_div.py b/t/unit/utils/test_div.py
index 2a63d140..b29b6119 100644
--- a/t/unit/utils/test_div.py
+++ b/t/unit/utils/test_div.py
@@ -1,6 +1,5 @@
import pickle
-
-from io import StringIO, BytesIO
+from io import BytesIO, StringIO
from kombu.utils.div import emergency_dump_state
diff --git a/t/unit/utils/test_encoding.py b/t/unit/utils/test_encoding.py
index cf50c746..26e3ef36 100644
--- a/t/unit/utils/test_encoding.py
+++ b/t/unit/utils/test_encoding.py
@@ -1,13 +1,9 @@
import sys
-
from contextlib import contextmanager
-
from unittest.mock import patch
-from kombu.utils.encoding import (
- get_default_encoding_file, safe_str,
- set_default_encoding_file, default_encoding,
-)
+from kombu.utils.encoding import (default_encoding, get_default_encoding_file,
+ safe_str, set_default_encoding_file)
@contextmanager
diff --git a/t/unit/utils/test_functional.py b/t/unit/utils/test_functional.py
index 162c16d9..42c53caf 100644
--- a/t/unit/utils/test_functional.py
+++ b/t/unit/utils/test_functional.py
@@ -1,18 +1,15 @@
import pickle
-
-import pytest
-
from itertools import count
-
from unittest.mock import Mock
+
+import pytest
from case import mock
from kombu.utils import functional as utils
-from kombu.utils.functional import (
- ChannelPromise, LRUCache, fxrange, fxrangemax, memoize, lazy,
- maybe_evaluate, maybe_list, reprcall, reprkwargs, retry_over_time,
- accepts_argument,
-)
+from kombu.utils.functional import (ChannelPromise, LRUCache, accepts_argument,
+ fxrange, fxrangemax, lazy, maybe_evaluate,
+ maybe_list, memoize, reprcall, reprkwargs,
+ retry_over_time)
class test_ChannelPromise:
diff --git a/t/unit/utils/test_imports.py b/t/unit/utils/test_imports.py
index 5dc95b75..8a4873df 100644
--- a/t/unit/utils/test_imports.py
+++ b/t/unit/utils/test_imports.py
@@ -1,7 +1,7 @@
-import pytest
-
from unittest.mock import Mock
+import pytest
+
from kombu import Exchange
from kombu.utils.imports import symbol_by_name
diff --git a/t/unit/utils/test_json.py b/t/unit/utils/test_json.py
index e3a8fa11..6af1c13b 100644
--- a/t/unit/utils/test_json.py
+++ b/t/unit/utils/test_json.py
@@ -1,12 +1,11 @@
-import pytest
-import pytz
-
from collections import namedtuple
from datetime import datetime
from decimal import Decimal
+from unittest.mock import MagicMock, Mock
from uuid import uuid4
-from unittest.mock import MagicMock, Mock
+import pytest
+import pytz
from kombu.utils.encoding import str_to_bytes
from kombu.utils.json import _DecodeError, dumps, loads
diff --git a/t/unit/utils/test_objects.py b/t/unit/utils/test_objects.py
index 330a7db5..93a88b4f 100644
--- a/t/unit/utils/test_objects.py
+++ b/t/unit/utils/test_objects.py
@@ -12,7 +12,7 @@ class test_cached_property:
def foo(self):
return 42
- @foo.deleter # noqa
+ @foo.deleter
def foo(self, value):
self.xx = value
@@ -32,7 +32,7 @@ class test_cached_property:
def foo(self):
return 42
- @foo.setter # noqa
+ @foo.setter
def foo(self, value):
self.xx = 10
diff --git a/t/unit/utils/test_scheduling.py b/t/unit/utils/test_scheduling.py
index 43bb7014..44cf01a2 100644
--- a/t/unit/utils/test_scheduling.py
+++ b/t/unit/utils/test_scheduling.py
@@ -1,7 +1,7 @@
-import pytest
-
from unittest.mock import Mock
+import pytest
+
from kombu.utils.scheduling import FairCycle, cycle_by_name
diff --git a/t/unit/utils/test_url.py b/t/unit/utils/test_url.py
index 18588bca..71ea0f9b 100644
--- a/t/unit/utils/test_url.py
+++ b/t/unit/utils/test_url.py
@@ -8,8 +8,8 @@ import ssl
import pytest
import kombu.utils.url
-from kombu.utils.url import as_url, parse_url, maybe_sanitize_url
-from kombu.utils.url import parse_ssl_cert_reqs
+from kombu.utils.url import (as_url, maybe_sanitize_url, parse_ssl_cert_reqs,
+ parse_url)
def test_parse_url():