Run the live test suite on one event loop - #31
Open
shauneccles wants to merge 1 commit into
Open
Conversation
The module shares one GLinet client and one aiohttp session, but with pytest-asyncio >= 0.26 the session-scoped event_loop fixture is ignored and each test gets its own function-scoped loop, so every test after the first fails with 'RuntimeError: Event loop is closed'. Mark the module with loop_scope="module" and drop the obsolete fixture and the now-redundant per-test markers. Verified against a GL-MT6000 (firmware 4.9.0), logs in the PR. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jul 11, 2026
Author
|
Friendly final ping on this one — it's been open a few months with the rest of my queue, so I'm doing a tidy-up pass. Since filing it, my fork has continued as the independent glinet4 project (https://github.com/glinet4/glinet4, on PyPI as |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The live suite shares one module-level
GLinetclient (and therefore one aiohttp session), but with current pytest-asyncio (>= 0.26, tested on 1.4.0) the custom session-scopedevent_loopfixture is silently ignored and every test gets its own function-scoped loop. The session binds to the first test's loop, so every subsequent test fails withRuntimeError: Event loop is closed— the live suite is unusable beyondtest_router_reachable.Fix
pytest.mark.asyncio(loop_scope="module")so all tests share one loop.event_loopfixture and the per-test@pytest.mark.asynciomarkers (they would override the module loop scope back to function scope).Test-only change; no library code touched.
Tested on real hardware
GL-MT6000 (Flint 2), firmware 4.9.0, pytest 9.1.1 / pytest-asyncio 1.4.0, non-disruptive tests only (
-k "not set_enabled and not wireguard_start and not wireguard_stop and not tailscale_start and not tailscale_stop and not reboot").Before (master):
After (this branch):
The 5 remaining failures are pre-existing assertion mismatches that depend on device configuration/firmware (they fail identically on master once the loop issue is fixed) — happy to follow up on those separately if useful.
🤖 Generated with Claude Code