Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue(s) with usage example: fixture 'mqtt_settings' not found #20

Closed
aaronkurz opened this issue Apr 11, 2024 · 4 comments
Closed

Issue(s) with usage example: fixture 'mqtt_settings' not found #20

aaronkurz opened this issue Apr 11, 2024 · 4 comments
Assignees

Comments

@aaronkurz
Copy link

I am encountering issues when trying to execute the basic example.

I am running pytest with this test:

from pytest_mqtt.model import MqttMessage
import pytest


@pytest.mark.capmqtt_decode_utf8
def test_mqtt_send_receive(mosquitto, capmqtt):
    """
    Basic send/receive roundtrip, using text payload (`str`).

    By using the `capmqtt_decode_utf8` marker, the message payloads
    will be recorded as `str`, after decoding them from `utf-8`.
    Otherwise, message payloads would be recorded as `bytes`.
    """
    # Submit a basic MQTT message.
    capmqtt.publish(topic="foo", payload="bar")

    # Demonstrate the "messages" property.
    # It returns a list of "MqttMessage" objects.
    assert capmqtt.messages == [
        MqttMessage(topic="foo", payload="bar", userdata=None),
    ]

    # Demonstrate the "records" property.
    # It returns tuples of "(topic, payload, userdata)".
    assert capmqtt.records == [
        ("foo", "bar", None),
    ]

However, I get the error

file /home/aaron/Developer/factory-activity-detection/mqtt_xes/venv/lib/python3.10/site-packages/pytest_mqtt/mosquitto.py, line 83
  @pytest.fixture(scope="session")
  def mosquitto(mqtt_settings: MqttSettings):
E       fixture 'mqtt_settings' not found

How can I fix this issue?

Furthermore, I noticed that import pytest is missing for the basic usage example.

@aaronkurz aaronkurz changed the title Issue(s) with usage example: Issue(s) with usage example: fixture 'mqtt_settings' not found Apr 11, 2024
@amotl
Copy link
Member

amotl commented Apr 30, 2024

Dear Aaron,

thanks a stack for your report.

It looks like the most recent release is bogus in this regard. I just observed the same error over here, coming from a Dependabot patch.

We will need to look into the issue, and fix it. Apologies for the hiccup, can you work around it by downgrading to the previous version in the meanwhile?

With kind regards,
Andreas.

@amotl amotl self-assigned this Apr 30, 2024
@amotl
Copy link
Member

amotl commented May 8, 2024

Hi. We just yanked the release 0.4.0 from PyPI, and there is a patch now, intending to fix the problem.

Apologies for the delay, release 0.4.1 is upcoming.

@amotl
Copy link
Member

amotl commented May 8, 2024

pytest-mqtt 0.4.1 has been released and verified on behalf of daq-tools/lorrystream#95. Closing this. Thanks again.

@amotl amotl closed this as completed May 8, 2024
@amotl
Copy link
Member

amotl commented May 8, 2024

Furthermore, I noticed that import pytest is missing for the basic usage example.

Thank you. Fixed with 3e410fb.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants