From d064721f6702300d3fc0277282db34422e1f1f60 Mon Sep 17 00:00:00 2001 From: piekstra Date: Fri, 30 Jan 2026 18:06:36 -0500 Subject: [PATCH 1/4] Fix CI workflow and update Python versions - Fix branch trigger: replace $default-branch template var with 'main' - Add pytest-asyncio to dependencies (required for async tests) - Update Python versions: test 3.10, 3.11, 3.12, 3.13 (drop EOL 3.9) - Use 'docker compose' (v2) instead of deprecated 'docker-compose' - Remove unnecessary docker-compose install step (pre-installed on runners) - Add wait step to ensure mock API is ready before tests Fixes #78 --- .github/workflows/python-package.yml | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 3e166a9..789fcdc 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -4,7 +4,7 @@ name: Python package on: push: - branches: [ $default-branch ] + branches: [ main ] pull_request: jobs: @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.9, 3.11, 3.12] + python-version: ['3.10', '3.11', '3.12', '3.13'] steps: - uses: actions/checkout@v4 @@ -21,22 +21,26 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - # Install Docker Compose - - name: Install Docker Compose - run: | - sudo apt-get update - sudo apt-get install -y docker-compose # Start this early in case it needs some "boot up time" - name: Start docker containers for tests run: | - docker-compose up -d mock-tplink-api + docker compose up -d mock-tplink-api - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install flake8 pytest + python -m pip install flake8 pytest pytest-asyncio if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Wait for mock API to be ready + run: | + for i in {1..30}; do + if curl -s http://127.0.0.1:8080 > /dev/null 2>&1; then + echo "Mock API is ready" + break + fi + echo "Waiting for mock API... ($i/30)" + sleep 1 + done - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names From b06e991da9fdb6d6aa48fb60bd3dc3fcc9face14 Mon Sep 17 00:00:00 2001 From: piekstra Date: Fri, 30 Jan 2026 18:11:48 -0500 Subject: [PATCH 2/4] Add pytest-asyncio configuration - Add pytest.ini with asyncio_mode = auto - Remove deprecated event_loop fixture from conftest.py (pytest-asyncio now handles this automatically) --- pytest.ini | 2 ++ tests/conftest.py | 8 -------- 2 files changed, 2 insertions(+), 8 deletions(-) create mode 100644 pytest.ini diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..2f4c80e --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +asyncio_mode = auto diff --git a/tests/conftest.py b/tests/conftest.py index b6f431e..578c1de 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,6 +1,5 @@ import os import pytest -import asyncio try: from .local_env_vars import ENV_VARS @@ -20,10 +19,3 @@ def tests_setup_and_teardown(): # Will be executed after the last test os.environ.clear() os.environ.update(original_environ) - - -@pytest.fixture(scope='module') -def event_loop(request): - loop = asyncio.get_event_loop_policy().new_event_loop() - yield loop - loop.close() From 566db883fe53685c0925cb573043dc57d7aee96b Mon Sep 17 00:00:00 2001 From: piekstra Date: Fri, 30 Jan 2026 18:13:07 -0500 Subject: [PATCH 3/4] Remove Python 3.13 from CI matrix Python 3.13 removed the 'cgi' module which is used by aiohttp 3.7.4. The freezegun package also has incompatibilities with Python 3.13. Adding Python 3.13 support requires updating dependencies: - aiohttp to 3.9+ - freezegun to 1.3+ Also set fail-fast: false so one Python version failure doesn't cancel others. --- .github/workflows/python-package.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 789fcdc..db244f1 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -12,8 +12,10 @@ jobs: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: - python-version: ['3.10', '3.11', '3.12', '3.13'] + # Note: Python 3.13 requires updated aiohttp and freezegun dependencies + python-version: ['3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v4 From 1321e5df0c0a23499ed5c0938bcac15f2ccdba9c Mon Sep 17 00:00:00 2001 From: piekstra Date: Fri, 30 Jan 2026 18:14:28 -0500 Subject: [PATCH 4/4] Remove deprecated event_loop fixture reference from test --- tests/test_device_manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_device_manager.py b/tests/test_device_manager.py index 93999e5..7461a3d 100644 --- a/tests/test_device_manager.py +++ b/tests/test_device_manager.py @@ -18,7 +18,7 @@ async def client(): ) -@pytest.mark.usefixtures('client', 'event_loop') +@pytest.mark.usefixtures('client') class TestGetDevices(object): @pytest.mark.asyncio