Skip to content

fix: detect async def test_ functions in project inspector#34

Merged
Nelson Spence (Fieldnote-Echo) merged 4 commits intoProject-Navi:mainfrom
RogueTex:fix/async-test-detection
Mar 11, 2026
Merged

fix: detect async def test_ functions in project inspector#34
Nelson Spence (Fieldnote-Echo) merged 4 commits intoProject-Navi:mainfrom
RogueTex:fix/async-test-detection

Conversation

@RogueTex
Copy link
Contributor

Description

The regex in src/navi_bootstrap/init.py (line 252) used to count test functions only matched synchronous def test_* functions:

# Before
count += len(re.findall(r"^\s*def test_", content, re.MULTILINE))

This missed async def test_* functions, causing test_count to be undercounted for projects using pytest-asyncio or any async test suite.

Type of Change

  • Bug fix
  • New feature
  • Documentation
  • Test coverage
  • Refactor
  • Security
  • Breaking change

Checklist

  • My code follows the project's style (ruff check src/navi_bootstrap/ tests/)
  • I have added tests for my changes
  • I have updated documentation if needed
  • All existing tests pass (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:

# After
count += len(re.findall(r"^\s*(?:async\s+)?def test_", content, re.MULTILINE))

A new test test_detects_async_test_functions was added to TestDetectTestInfo to cover this case.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 async before def.
  • 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 AI review requested due to automatic review settings March 10, 2026 16:32
@RogueTex
Copy link
Contributor Author

Copilot open a new pull request to apply changes based on the comments in this thread

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 10, 2026 16:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@Fieldnote-Echo
Copy link
Member

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.

Copy link
Collaborator

@project-navi-bot project-navi-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All required CI checks passed. Auto-approved by navi-bot.

Copy link
Collaborator

@project-navi-bot project-navi-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-approved by navi-bot.

@Fieldnote-Echo Nelson Spence (Fieldnote-Echo) merged commit 8e3cf93 into Project-Navi:main Mar 11, 2026
3 of 4 checks passed
Nelson Spence (Fieldnote-Echo) added a commit that referenced this pull request Mar 12, 2026
Reverts changes from:
- #35 (passionworkeer): CLI help text additions
- #34 (RogueTex): async test detection regex

Issues #30 and #32 remain open for proper reimplementation.
Nelson Spence (Fieldnote-Echo) added a commit that referenced this pull request Mar 12, 2026
Reverts changes from:
- #35 (passionworkeer): CLI help text additions
- #34 (RogueTex): async test detection regex

Issues #30 and #32 remain open for proper reimplementation.
@Fieldnote-Echo
Copy link
Member

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix async test function detection in project inspector

4 participants