test: get pytest working with basic DB tests#45
Open
AlexCLeduc wants to merge 10 commits intomainfrom
Open
Conversation
AlexCLeduc
commented
Apr 23, 2026
Author
There was a problem hiding this comment.
I'm surprised we've gotten this far without __init__.py modules, but they're at least required for coverage to properly index/identify files, so please add __init__.py files all around from now on
AlexCLeduc
commented
Apr 23, 2026
Comment on lines
+525
to
+534
| ## Running tests | ||
|
|
||
| From the backend/ directory, | ||
| 1. `pip install -r requirements_dev.txt` | ||
| 2. `pytest` | ||
|
|
||
| To calculate coverage, | ||
| 1. `coverage run -m pytest` | ||
| 2. `coverage html` | ||
| 3. Open `./htmlcov/index.html` in a browser to view the report and browse around line by line |
AlexCLeduc
commented
Apr 23, 2026
Comment on lines
+105
to
+124
| - name: Publish diff coverage comment | ||
| if: github.event.pull_request.base.sha != '' | ||
| continue-on-error: true | ||
| uses: edumserrano/find-create-or-update-comment@v2 | ||
| with: | ||
| issue-number: ${{ github.event.pull_request.number }} | ||
| body-includes: '<!-- can-sr-diff-coverage -->' | ||
| comment-author: 'github-actions[bot]' | ||
| body-path: backend/diff-coverage-comment.md | ||
| edit-mode: replace | ||
|
|
||
| - name: Upload coverage artifacts | ||
| if: always() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: coverage-reports | ||
| if-no-files-found: ignore | ||
| path: | | ||
| backend/coverage.xml | ||
| backend/diff-cover.html |
Author
There was a problem hiding this comment.
Ideally, this action would add a comment on each PR listing the coverage of its diff. Unfortunately I can't easily get this working, running into permission issues I don't have time to debug.
It does hoever successfully upload an artifact you can download, but that's not much faster than checking coverage yourself locally
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.
introducing backend/tests/
if you're writing a test that need the database (most tests I think), make sure it's nested under
backend/tests/with_db/(we may combine these tests later, but I wanted to have an area people could test non-DB dependent tests easily without needing the DB infrastructure configured)