Repository navigation
Add a CPython test suite and coverage reporting - #115
Merged
Merged
Conversation
- tests/: pytest suite for all modules, using real loopback sockets and in-memory fake sockets. Known bugs are strict xfails; open questions are skips with a reason. tests/README.md explains both. - .coveragerc: branch coverage, exclusions for CircuitPython-only code, and a list of lines still counted as missed on purpose. - .github/workflows/coverage.yml: runs the tests under coverage and puts the report in the job summary. Separate so build.yml stays standard. - .gitignore: ignore .coverage. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mikeysklar
approved these changes
Nov 19, 2026
mikeysklar
left a comment
Contributor
There was a problem hiding this comment.
Works as advertised.
| Check | Result |
|---|---|
| 5 runs, Python 3.14 | 334 passed, 6 skipped, 28 xfailed each time, under 1 s |
| 5 random orders (pytest-randomly) | same result each time |
ResourceWarning (leaked sockets) |
none |
| Coverage | 99%, branch coverage on |
| pre-commit | ruff, ruff format, reuse pass |
xfails with --runxfail |
all 28 fail for the bug their reason names |
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.
Tests and coverage setup written by Claude, reviewed by @dhalbert.
This library had no tests. This PR adds a pytest suite that runs on CPython, and reports test coverage in CI.
This PR does not change the library itself. The test generation found issues which will be fixed separately.
Tests
tests/has tests for every module. MostServertests use real sockets on 127.0.0.1, with routes based on the examples. Error paths that are hard to cause with real sockets (EAGAIN, ECONNRESET, timeouts, partial sends) use in-memory fake sockets.python -m pytestwhen atests/directory exists, sobuild.ymlis unchanged.tests/README.mdexplains how to run the tests and how they are organized.Known bugs and open questions
The library has a bunch of behavior that looks wrong now. The problems are marked rather than asserted as correct, so that the tests are present but don't cause the CI to fail. We'll need to whittle this list down to zero through PRs.
xfail(strict=True). Each one asserts the correct behavior for a known bug. When the bug is fixed, the test passes, andstrict=Truemakes CI fail until the marker is removed.python -m pytest -rxslists them all with their reasons.The bugs most likely to affect users:
application/x-www-form-urlencodedare not decoded, so+and%XXescapes come back as sent.poll()raise instead of answering 400.poll()raiseSSLError.Websocket.receive()raises instead of closing when the client disconnects.request.cookiesraisesValueErroron a cookie without=.Coverage
.github/workflows/coverage.ymlruns the tests under coverage and puts the report in the job summary. It is a separate workflow so thatbuild.ymlstays identical to the other libraries' copies..coveragercturns on branch coverage and excludes code that cannot run on CPython, such as CircuitPython import fallbacks and CircuitPython-only SSL setup. A comment lists the lines still counted as missed on purpose: a path blocked by a known bug, and dead code..gitignoreignores.coverage, as requests, minimqtt and connection_manager already do.