diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 466b93f..0cab52a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,6 +8,7 @@ on: jobs: test: runs-on: ubuntu-latest + timeout-minutes: 10 strategy: matrix: python-version: ["3.11", "3.12", "3.13"] @@ -20,4 +21,4 @@ jobs: - run: ruff check src/ tests/ - run: ruff format --check src/ tests/ - run: mypy src/ - - run: pytest + - run: pytest -v --timeout=30 diff --git a/pyproject.toml b/pyproject.toml index 1695ff7..1ee16d0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,6 +49,7 @@ dev = [ "pytest-httpx>=0.34", "pytest-xdist>=3.0", "pytest-cov>=5.0", + "pytest-timeout>=2.3", "ruff>=0.8", "mypy>=1.13", "mypy-protobuf>=3.6", @@ -88,6 +89,7 @@ plugins = ["pydantic.mypy"] testpaths = ["tests"] asyncio_mode = "auto" addopts = "-n auto -m 'not e2e'" +timeout = 30 markers = [ "e2e: End-to-end smoke tests against the live Tesla Fleet API (requires TESLA_ACCESS_TOKEN)", ] diff --git a/tests/telemetry/test_tui.py b/tests/telemetry/test_tui.py index 6614c1d..20522e4 100644 --- a/tests/telemetry/test_tui.py +++ b/tests/telemetry/test_tui.py @@ -310,14 +310,15 @@ async def test_unknown_field_goes_to_diagnostics(self) -> None: @pytest.mark.asyncio async def test_queue_overflow_drops_silently(self) -> None: + # Test the overflow behavior directly without Textual's run_test(), + # which deadlocks on Python 3.11 due to ContextVar + event loop + # scheduling differences between 3.11 and 3.12+. app = TelemetryTUI(vin=VIN) - async with app.run_test(): - # Fill the queue. - for i in range(110): - await app.push_frame(_frame(("BatteryLevel", 8, 80 - i, "int"))) + for i in range(110): + await app.push_frame(_frame(("BatteryLevel", 8, 80 - i, "int"))) - # No exception should be raised — overflow is silent. - assert app._queue.qsize() <= 100 + # No exception should be raised — overflow is silent. + assert app._queue.qsize() <= 100 @pytest.mark.asyncio async def test_server_info_setters(self) -> None: