diff --git a/pyproject.toml b/pyproject.toml index 6250fd67..85de0d3e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,7 +27,6 @@ dependencies = [ "PyYAML>=6.0.1,<7", "jmespath>=1,<2", "jsonschema>=4,<5", - "paho-mqtt>=1.3.1,<=1.6.1", "pyjwt>=2.5.0,<3", "pykwalify>=1.8.0,<2", "pytest>=7,<7.3", @@ -89,6 +88,9 @@ dev = [ # "tbump@https://github.com/michaelboulton/tbump/archive/714ba8957a3c84b625608ceca39811ebe56229dc.zip", ] +mqtt = [ + "paho-mqtt>=1.3.1,<=1.6.1", +] [project.scripts] diff --git a/tavern/_core/plugins.py b/tavern/_core/plugins.py index 5120de48..29e8fe26 100644 --- a/tavern/_core/plugins.py +++ b/tavern/_core/plugins.py @@ -4,6 +4,7 @@ significantly if/when a proper plugin system is implemented! """ import dataclasses +import importlib.util import logging from functools import partial from typing import Any, List, Mapping, Optional @@ -105,7 +106,12 @@ def enabled(current_backend, ext): ext.name == test_block_config.tavern_internal.backends[current_backend] ) - for backend in ["http", "mqtt"]: + backends = ["http"] + + if importlib.util.find_spec("paho.mqtt") is not None: + backends.append("mqtt") + + for backend in backends: namespace = "tavern_{}".format(backend) manager = stevedore.EnabledExtensionManager( diff --git a/tests/conftest.py b/tests/conftest.py index a770e583..a0c6ea2a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -6,7 +6,8 @@ import yaml import tavern -import tavern._plugins.mqtt.tavernhook as mqtt_plugin + +# import tavern._plugins.mqtt.tavernhook as mqtt_plugin from tavern._plugins.rest.tavernhook import TavernRestPlugin as rest_plugin @@ -28,8 +29,8 @@ def extension(name, point): "requests", rest_plugin, ), - extension( - "paho-mqtt", - mqtt_plugin, - ), + # extension( + # "paho-mqtt", + # mqtt_plugin, + # ), ] diff --git a/tox-integration.ini b/tox-integration.ini index e4eeea81..d06eae8d 100644 --- a/tox-integration.ini +++ b/tox-integration.ini @@ -6,6 +6,8 @@ isolated_build = True [testenv] allowlist_externals = docker +extras = + mqtt: mqtt basepython = python3.11 passenv = DOCKER_TLS_VERIFY,DOCKER_HOST,DOCKER_CERT_PATH,DOCKER_BUILDKIT setenv = diff --git a/tox.ini b/tox.ini index 17e0c0bd..e5c32851 100644 --- a/tox.ini +++ b/tox.ini @@ -11,6 +11,7 @@ allowlist_externals = install_command = python -m pip install {opts} {packages} -c constraints.txt extras = dev + mqtt commands = {envbindir}/python -m pytest --cov-report term-missing --cov tavern {posargs}