Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,45 @@ name: Python package

on:
push:
branches: [ $default-branch ]
branches: [ main ]
pull_request:

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.9, 3.11, 3.12]
# Note: Python 3.13 requires updated aiohttp and freezegun dependencies
python-version: ['3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
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
Expand Down
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
asyncio_mode = auto
8 changes: 0 additions & 8 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
import pytest
import asyncio

try:
from .local_env_vars import ENV_VARS
Expand All @@ -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()
2 changes: 1 addition & 1 deletion tests/test_device_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async def client():
)


@pytest.mark.usefixtures('client', 'event_loop')
@pytest.mark.usefixtures('client')
class TestGetDevices(object):

@pytest.mark.asyncio
Expand Down