From 35c34fb28bbd9c16241b93a068865d9ed9b65c6e Mon Sep 17 00:00:00 2001 From: Guido Schmitz Date: Mon, 6 Oct 2025 20:36:40 +0200 Subject: [PATCH 1/2] Run tests on Python 3.14 --- .github/workflows/pythonpackage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 015335c..c911748 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -47,7 +47,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] steps: - name: Checkout sources uses: actions/checkout@v5.0.0 From 88bfd6e8c1e8d438f9c083486f58960bda1a783b Mon Sep 17 00:00:00 2001 From: Guido Schmitz Date: Mon, 6 Oct 2025 21:00:37 +0200 Subject: [PATCH 2/2] Fix asyncio usage --- devolo_plc_api/device.py | 6 ++---- tests/test_device.py | 2 -- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/devolo_plc_api/device.py b/devolo_plc_api/device.py index 4bfdec8..a6d4a5a 100644 --- a/devolo_plc_api/device.py +++ b/devolo_plc_api/device.py @@ -65,7 +65,6 @@ def __init__( self._zeroconf_instance = zeroconf_instance logging.captureWarnings(capture=True) - self._loop: asyncio.AbstractEventLoop self._session: AsyncClient self._zeroconf: AsyncZeroconf @@ -148,8 +147,7 @@ async def async_connect(self, session_instance: AsyncClient | None = None) -> No def connect(self) -> None: """Connect to a device synchronous.""" - self._loop = asyncio.get_event_loop() - self._loop.run_until_complete(self.async_connect()) + asyncio.run(self.async_connect()) async def async_disconnect(self) -> None: """Disconnect from a device asynchronous.""" @@ -164,7 +162,7 @@ async def async_disconnect(self) -> None: def disconnect(self) -> None: """Disconnect from a device synchronous.""" - self._loop.run_until_complete(self.async_disconnect()) + asyncio.run(self.async_disconnect()) async def _get_relevant_interfaces(self) -> list[str]: """Get the IP address of the relevant interface to reduce traffic.""" diff --git a/tests/test_device.py b/tests/test_device.py index e732966..d6c3c35 100644 --- a/tests/test_device.py +++ b/tests/test_device.py @@ -1,6 +1,5 @@ """Test communicating with a devolo device.""" -from asyncio import get_event_loop from unittest.mock import AsyncMock, Mock, patch import pytest @@ -107,7 +106,6 @@ async def test_async_disconnect(self, mock_device: Device): def test_disconnect(self, mock_device: Device): """Test that the sync disconnect method just calls the async disconnect method.""" with patch("devolo_plc_api.device.Device.async_disconnect", new=AsyncMock()) as ad: - mock_device._loop = get_event_loop() mock_device.disconnect() assert ad.call_count == 1