diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index ccfdd4b5..6ae8ad38 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -10,6 +10,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: actions/checkout@v4 + with: + repository: eclipse/paho.mqtt.testing + ref: a4dc694010217b291ee78ee13a6d1db812f9babd + path: paho.mqtt.testing - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} diff --git a/README.rst b/README.rst index f36c9a50..c80e6854 100644 --- a/README.rst +++ b/README.rst @@ -72,6 +72,8 @@ Once you have the code, it can be installed from your repository as well: To perform all test (including MQTT v5 test), you also need to clone paho.mqtt.testing in paho.mqtt.python folder:: git clone https://github.com/eclipse/paho.mqtt.testing.git + cd paho.mqtt.testing + git checkout a4dc694010217b291ee78ee13a6d1db812f9babd Known limitations ----------------- diff --git a/tests/test_mqttv5.py b/tests/test_mqttv5.py index 7c5cb464..e360491f 100644 --- a/tests/test_mqttv5.py +++ b/tests/test_mqttv5.py @@ -23,6 +23,7 @@ import time import traceback import unittest +import unittest.mock import paho.mqtt import paho.mqtt.client @@ -167,18 +168,22 @@ def setUpClass(cls): except ImportError: raise unittest.SkipTest("paho.mqtt.testing not present.") - cls._test_broker = threading.Thread( - target=mqtt.brokers.run, - kwargs={ - "config": ["listener 0"], - }, - ) - cls._test_broker.daemon = True - cls._test_broker.start() - # Wait a bit for TCP server to bind to an address - time.sleep(0.5) - # Hack to find the port used by the test broker... - cls._test_broker_port = mqtt.brokers.listeners.TCPListeners.server.socket.getsockname()[1] + # Hack: we need to patch `signal.signal()` because `mqtt.brokers.run()` + # calls it to set up a signal handler; however, that won't work + # from a thread... + with unittest.mock.patch("signal.signal", unittest.mock.MagicMock()): + cls._test_broker = threading.Thread( + target=mqtt.brokers.run, + kwargs={ + "config": ["listener 0"], + }, + ) + cls._test_broker.daemon = True + cls._test_broker.start() + # Wait a bit for TCP server to bind to an address + time.sleep(0.5) + # Hack to find the port used by the test broker... + cls._test_broker_port = mqtt.brokers.listeners.TCPListeners.server.socket.getsockname()[1] setData() cleanup(cls._test_broker_port)