From 4a8bab30e99207ba55a7adb4419a3c750ee64604 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Wed, 8 May 2024 22:57:46 +0200 Subject: [PATCH] Fix command line options machinery ... by refactoring essential pytest fixtures to the main package. They have been added to `testing` beforehand, which is just plain wrong, and broke the 0.4.0 release. --- CHANGES.rst | 3 +++ pytest_mqtt/mosquitto.py | 13 +++++++++++++ testing/conftest.py | 16 ---------------- 3 files changed, 16 insertions(+), 16 deletions(-) delete mode 100644 testing/conftest.py diff --git a/CHANGES.rst b/CHANGES.rst index 46f929e..6fadbcb 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,9 @@ pytest-mqtt changelog in progress =========== +- Fix command line options machinery by refactoring essential + pytest fixtures to the main package. They have been added to ``testing`` + beforehand, which is just plain wrong, and broke the 0.4.0 release. 2024-03-31 0.4.0 ================ diff --git a/pytest_mqtt/mosquitto.py b/pytest_mqtt/mosquitto.py index debe9ae..573502c 100644 --- a/pytest_mqtt/mosquitto.py +++ b/pytest_mqtt/mosquitto.py @@ -80,6 +80,19 @@ def is_mosquitto_running(host: str, port: int) -> bool: return probe_tcp_connect(host, port) +def pytest_addoption(parser) -> None: + parser.addoption("--mqtt-host", action="store", type=str, default="localhost", help="MQTT host name") + parser.addoption("--mqtt-port", action="store", type=int, default=1883, help="MQTT port number") + + +@pytest.fixture(scope="session") +def mqtt_settings(pytestconfig) -> MqttSettings: + return MqttSettings( + host=pytestconfig.getoption("--mqtt-host"), + port=pytestconfig.getoption("--mqtt-port"), + ) + + @pytest.fixture(scope="session") def mosquitto(mqtt_settings: MqttSettings): diff --git a/testing/conftest.py b/testing/conftest.py deleted file mode 100644 index f2c67de..0000000 --- a/testing/conftest.py +++ /dev/null @@ -1,16 +0,0 @@ -import pytest - -from pytest_mqtt.model import MqttSettings - - -def pytest_addoption(parser) -> None: - parser.addoption("--mqtt-host", action="store", type=str, default="localhost", help="MQTT host name") - parser.addoption("--mqtt-port", action="store", type=int, default=1883, help="MQTT port number") - - -@pytest.fixture(scope="session") -def mqtt_settings(pytestconfig) -> MqttSettings: - return MqttSettings( - host=pytestconfig.getoption("--mqtt-host"), - port=pytestconfig.getoption("--mqtt-port"), - )