TST: add hub-free unit tests for pyvo.samp.client - #779
Open
SebastianFoss wants to merge 1 commit into
Open
Conversation
SebastianFoss
marked this pull request as ready for review
August 4, 2026 01:53
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #779 +/- ##
==========================================
+ Coverage 80.52% 81.41% +0.88%
==========================================
Files 90 90
Lines 10352 10352
==========================================
+ Hits 8336 8428 +92
+ Misses 2016 1924 -92 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
|
Thank you for tackling this. I'll check the tests in details later, but for your question about |
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.
TST: add hub-free unit tests for
pyvo.samp.clientSummary
Adds 45 unit tests for
pyvo/samp/client.pythat require no hub, no sockets, and notime.sleep. All 6 existing tests are unchanged.Coverage
pytest pyvo/samp/tests/test_client.pypytest pyvo/samppytest pyvo/samp --slowRaw
'--cov-report=term-missingoutput================================ tests coverage ================================
_______________ coverage: platform linux, python 3.13.11-final-0 _______________
Name Stmts Miss Cover Missing
pyvo/samp/client.py 220 143 35% 4-58, 76, 79, 102-106, 147, 158, 175-180, 186-193, 197, 201-202, 207, 211-615, 621, 626, 631, 644, 649-653, 664-668, 672, 677, 687, 692-720, 732-742
TOTAL 220 143 35%
========================= 4 passed, 1 skipped in 0.40s =========================
=== BEFORE pytest pyvo/samp ===
$ pytest pyvo/samp
================================ tests coverage ================================
_______________ coverage: platform linux, python 3.13.11-final-0 _______________
Name Stmts Miss Cover Missing
pyvo/samp/client.py 220 94 57% 4-58, 76, 79, 102-106, 147, 158, 175-180, 186-193, 197, 201-202, 211-233, 249, 255, 287, 304, 339, 346, 381-422, 462-464, 505-507, 531-615, 621, 626, 631, 644, 649-653, 664-668, 672, 687, 692-698, 714-720, 732
TOTAL 220 94 57%
======================== 18 passed, 45 skipped in 1.63s ========================
=== BEFORE pytest pyvo/samp --slow ===
$ pytest pyvo/samp --slow
================================ tests coverage ================================
_______________ coverage: platform linux, python 3.13.11-final-0 _______________
Name Stmts Miss Cover Missing
pyvo/samp/client.py 220 94 57% 4-58, 76, 79, 102-106, 147, 158, 175-180, 186-193, 197, 201-202, 211-233, 249, 255, 287, 304, 339, 346, 381-422, 462-464, 505-507, 531-615, 621, 626, 631, 644, 649-653, 664-668, 672, 687, 692-698, 714-720, 732
TOTAL 220 94 57%
======================== 21 passed, 42 skipped in 5.65s ========================
=== AFTER pytest pyvo/samp/tests/test_client.py ===
$ pytest pyvo/samp/tests/test_client.py
================================ tests coverage ================================
_______________ coverage: platform linux, python 3.13.11-final-0 _______________
Name Stmts Miss Cover Missing
pyvo/samp/client.py 220 54 75% 4-58, 102-106, 147, 158, 179-180, 186-187, 193, 197, 201-202, 207, 211, 216, 233, 255, 287, 304, 339, 346, 381, 422, 464, 507, 533, 555, 577, 591, 615, 653, 668, 672, 698, 720, 732
TOTAL 220 54 75%
======================== 50 passed, 1 skipped in 0.73s =========================
=== AFTER pytest pyvo/samp ===
$ pytest pyvo/samp
================================ tests coverage ================================
_______________ coverage: platform linux, python 3.13.11-final-0 _______________
Name Stmts Miss Cover Missing
pyvo/samp/client.py 220 53 76% 4-58, 102-106, 147, 158, 179-180, 186-187, 193, 197, 201-202, 211, 216, 233, 255, 287, 304, 339, 346, 381, 422, 464, 507, 533, 555, 577, 591, 615, 653, 668, 672, 698, 720, 732
TOTAL 220 53 76%
======================== 64 passed, 45 skipped in 1.86s ========================
=== AFTER pytest pyvo/samp --slow ===
$ pytest pyvo/samp --slow
================================ tests coverage ================================
_______________ coverage: platform linux, python 3.13.11-final-0 _______________
Name Stmts Miss Cover Missing
pyvo/samp/client.py 220 53 76% 4-58, 102-106, 147, 158, 179-180, 186-187, 193, 197, 201-202, 211, 216, 233, 255, 287, 304, 339, 346, 381, 422, 464, 507, 533, 555, 577, 591, 615, 653, 668, 672, 698, 720, 732
TOTAL 220 53 76%
======================== 67 passed, 42 skipped in 5.97s ========================'
Note: the
4-58block in every Missing column is the module-level import and class-header region, executed at import time beforepytest-covbegins tracing. Excluding those ~15 statements, executable-logic coverage goes from ~61% to ~81%.Approach
Rather than adding hub-dependent integration tests, this introduces a
StubHubProxysatisfying the small interfaceSAMPClientactually uses. Covers: registration error branches, bind/unbind and thecallable=Falserejection paths, the built-insamp.app.pingandclient.env.gethandlers, notification/call/response dispatch (5- vs 6-arg handler signatures, wildcard MType matching, private-key mismatch), subscription and metadata declaration, and the start/stop lifecycle.Relation to #731
This does not fix #731. It is relevant to it in two ways:
test_client.pyalone reached 35% while the full suite reached 57% — the 22-point gap came from the hub-based tests that CI: MacOS SAMP tests hang indefinitely #731 implicates. After this PR that gap is a single statement (line 207). The flaky tests are no longer load-bearing forclient.pycoverage.--slowtests add zeroclient.pycoverage in both the before and after measurements.Two new tests (
test_start_and_stop_callable_client,test_stop_raises_if_thread_does_not_terminate) do start a thread, but synchronize viajoin(timeout)rather thansleep(). Happy to mark themslowif preferred.Incidental finding
SAMPClient.stop()'s secondif self._thread.is_alive()is not guarded byself._callable, so callingstop()on a client constructed withcallable=FalseraisesAttributeError. Not patched here — can fix in this PR or file separately.