diff options
Diffstat (limited to 't/unit/transport')
-rw-r--r-- | t/unit/transport/test_SQS.py | 17 | ||||
-rw-r--r-- | t/unit/transport/test_azureservicebus.py | 25 | ||||
-rw-r--r-- | t/unit/transport/test_base.py | 9 | ||||
-rw-r--r-- | t/unit/transport/test_consul.py | 5 | ||||
-rw-r--r-- | t/unit/transport/test_etcd.py | 5 | ||||
-rw-r--r-- | t/unit/transport/test_filesystem.py | 4 | ||||
-rw-r--r-- | t/unit/transport/test_librabbitmq.py | 4 | ||||
-rw-r--r-- | t/unit/transport/test_memory.py | 5 | ||||
-rw-r--r-- | t/unit/transport/test_mongodb.py | 7 | ||||
-rw-r--r-- | t/unit/transport/test_pyamqp.py | 3 | ||||
-rw-r--r-- | t/unit/transport/test_pyro.py | 5 | ||||
-rw-r--r-- | t/unit/transport/test_qpid.py | 12 | ||||
-rw-r--r-- | t/unit/transport/test_redis.py | 11 | ||||
-rw-r--r-- | t/unit/transport/test_sqlalchemy.py | 4 | ||||
-rw-r--r-- | t/unit/transport/test_zookeeper.py | 1 | ||||
-rw-r--r-- | t/unit/transport/virtual/test_base.py | 8 | ||||
-rw-r--r-- | t/unit/transport/virtual/test_exchange.py | 5 |
17 files changed, 62 insertions, 68 deletions
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 |