fix: detect async def test_ functions in project inspector#34
Conversation
Add test for detecting async test functions and update assertions.
There was a problem hiding this comment.
Pull request overview
This PR fixes inspect_project’s test counting by updating detect_test_info() to detect both synchronous def test_* and asynchronous async def test_* pytest tests, and adds coverage for the async case.
Changes:
- Update the regex used to count tests to include optional
asyncbeforedef. - Add a new test intended to verify async test functions are counted.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/navi_bootstrap/init.py |
Expands the test-function counting regex to match async def test_* as well as def test_*. |
tests/test_init.py |
Adds a new test case for async test detection (currently introduced with invalid Python formatting). |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Copilot open a new pull request to apply changes based on the comments in this thread |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Hey Raghu :) (@RogueTex) — thanks for picking this up! The core fix is solid. We're currently drafting contributor guidelines (CONTRIBUTING.md) to make expectations around formatting, local checks, and PR structure clearer. Once that's in place, we'll circle back with specific feedback on this PR. Sit tight — more to come shortly. |
project-navi-bot
left a comment
There was a problem hiding this comment.
All required CI checks passed. Auto-approved by navi-bot.
project-navi-bot
left a comment
There was a problem hiding this comment.
Auto-approved by navi-bot.
8e3cf93
into
Project-Navi:main
|
Hey Raghu :) (@RogueTex) — apologies for the mess here. We had some CI infrastructure changes going through (ruleset updates, check name standardization) and your PR got caught in the crossfire during the migration. We've reverted and recreated your changes in #42 with proper attribution. We'll provide substantive feedback on the PR tomorrow. Thanks for your patience and your contribution! |
Description
The regex in
src/navi_bootstrap/init.py(line 252) used to count test functions only matched synchronousdef test_*functions:This missed
async def test_*functions, causingtest_countto be undercounted for projects usingpytest-asyncioor any async test suite.Type of Change
Checklist
ruff check src/navi_bootstrap/ tests/)pytest tests/ -v)Related Issues
Fixes #32
Additional Notes
The fix updates the regex to use a non-capturing optional group
(?:async\s+)?so both sync and async test functions are detected:A new test
test_detects_async_test_functionswas added toTestDetectTestInfoto cover this case.