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 <module>
    from kombu.transport import azureservicebus
kombu/transport/azureservicebus.py:66: in <module>
    import azure.core.exceptions
E   ModuleNotFoundError: No module named 'azure'
```

* Add # noqa to make linter happy
This commit is contained in:
Felix Yan 2021-06-11 15:21:09 +08:00 committed by GitHub
parent 89b92f7f2c
commit e5dbfed8ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 4 deletions

View File

@ -9,11 +9,10 @@ from collections import namedtuple
from kombu import messaging from kombu import messaging
from kombu import Connection, Exchange, Queue from kombu import Connection, Exchange, Queue
from kombu.transport import azureservicebus
import azure.servicebus.exceptions
import azure.core.exceptions
pytest.importorskip('azure.servicebus') 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 from azure.servicebus import ServiceBusMessage, ServiceBusReceiveMode # noqa