change: convert the test scripts to pytest #38
Loading…
Reference in a new issue
No description provided.
Delete branch "change/tests-to-pytest"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
First half of #25 (the conversion; the CI job needs a runner decision first, see below). Closes #30 -- the raw-string commit is that issue's exact fix. Stacked on #37 -- the first four commits here are that PR and will disappear from this diff when it merges.
Problem
Five standalone scripts, each with its own copy-pasted
check()harness (one had already drifted), each named after the bug that prompted it -- so the directory grows with the bug history, and there is no single runner, no selection, no fixtures.Fix
pytest, with files named after the module under test:
test_update.py(import guard, credentials,ovpn_quote),test_tunnel.py,test_aqomui_gui.py, plus oneconftest.py. Same coverage, same rationale docstrings, shared fixtures instead of five harness copies. The OpenVPN-parser cases keep their skip when the binary is absent (skipif).tests/manual/stays uncollected. CONTRIBUTING gains a Testing section stating the layout rule and the no-root/network/account/display line.Also fixes the three
'\d'regex literals to raw strings -- a SyntaxWarning today, a SyntaxError in a future Python, and the thing a-W error::SyntaxWarningCI step would trip on.Verification
pytest -q: 23 passed.python -W error::SyntaxWarning -m compileall aqomui tests: clean.ruff check --select E9,F63,F7,F82: clean -- so the future CI lint gate can start strict with no code changes.Notes
tests/test_scripts_button.py; once it lands, that script needs the same mechanical conversion (its cases belong intest_aqomui_gui.py).🤖 Generated with Claude Code
TunnelThread.run caught only KeyError, and that except was the OpenVPN dispatch fallback, not a guard -- anything else raised while establishing a tunnel reached the top of the QThread and PyQt5 aborted the root service, dropping every active tunnel. The fallback also rerouted a KeyError raised anywhere inside wireguard() into openvpn() with a WireGuard server dict. TunnelThread now runs on GuardedThread: the dispatch keys on server_dict.get("tunnel"), so a missing key still means OpenVPN, and an escaped error ends as conn_attempt_failed -- the status the GUI already answers with cleanup and a notification. report_failure also deletes the outbound allow rule(s) the attempt inserted, which nothing else takes back on this path. tests/test_tunnel_failure.py covers it (no root, network or account) and fails against the unfixed code, including the wireguard-to-openvpn reroute. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>