From e5dbfed8ae9fb5e7d2d76be682517a9779137c77 Mon Sep 17 00:00:00 2001 From: Felix Yan Date: Fri, 11 Jun 2021 15:21:09 +0800 Subject: [PATCH] Move pytest.importorskip to run earlier (#1346) * Move pytest.importorskip to run earlier Currently pytest fails to collect tests when `azure` is not present. Moving the pytest.importorskip clause before `from kombu.transport import azureservicebus` fixes it. ``` ==================================== ERRORS ==================================== __________ ERROR collecting t/unit/transport/test_azureservicebus.py ___________ ImportError while importing test module '/build/python-kombu/src/kombu-5.1.0/t/unit/transport/test_azureservicebus.py'. Hint: make sure your test modules/packages have valid Python names. Traceback: /usr/lib/python3.9/importlib/__init__.py:127: in import_module return _bootstrap._gcd_import(name[level:], package, level) t/unit/transport/test_azureservicebus.py:12: in from kombu.transport import azureservicebus kombu/transport/azureservicebus.py:66: in import azure.core.exceptions E ModuleNotFoundError: No module named 'azure' ``` * Add # noqa to make linter happy --- t/unit/transport/test_azureservicebus.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/t/unit/transport/test_azureservicebus.py b/t/unit/transport/test_azureservicebus.py index bc96bbff..47cc9fd5 100644 --- a/t/unit/transport/test_azureservicebus.py +++ b/t/unit/transport/test_azureservicebus.py @@ -9,11 +9,10 @@ from collections import namedtuple from kombu import messaging from kombu import Connection, Exchange, Queue -from kombu.transport import azureservicebus -import azure.servicebus.exceptions -import azure.core.exceptions 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