Skip to content

Commit

Permalink
paho-mqtt: Ignore deprecation warnings about Callback API v1
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Oct 19, 2024
1 parent 900aa2f commit bf7e2b5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pytest-mqtt changelog

in progress
===========
- paho-mqtt: Ignore deprecation warnings about Callback API v1

2024-07-29 0.4.2
================
Expand Down
5 changes: 4 additions & 1 deletion pytest_mqtt/capmqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import logging
import threading
import typing as t
import warnings

import paho.mqtt.client as mqtt
import pytest
Expand All @@ -35,7 +36,9 @@ def __init__(self, on_message_callback: t.Optional[t.Callable] = None, host: str
self.client = mqtt.Client()
else:
# paho-mqtt 2.x
self.client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION1)
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
self.client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION1)
self.on_message_callback = on_message_callback
self.host = host
self.port = int(port)
Expand Down

0 comments on commit bf7e2b5

Please sign in to comment.