Skip to content

fix: report a test module that fails to import - #226

Merged
JarbasAl merged 1 commit into
devfrom
fix/broken-test-module-collects-nothing
Oct 22, 2026
Merged

JarbasAl merged 1 commit into
devfrom
fix/broken-test-module-collects-nothing

Conversation

@openvoiceos-bot

Copy link
Copy Markdown
Contributor

🤖 Auto-generated by Claude Opus 5.5 (claude-opus-5-5) via Claude Code — NOT human-reviewed. Verify before acting.

What changes

A test module that fails to import is reported as a collection error again. Before this fix, a repo that runs pytest with --import-mode=importlib and has ovoscope installed collected such a module as zero tests with no error, so CI stayed green.

Cause: the pytest_pycollect_makemodule wrapper imports every test module, to look for ovoscope_intent_cases, and swallows any failure. In importlib mode the half-run module stays in sys.modules. pytest's own import then returns it. It has none of the tests defined after the failing line, and pytest has no error to show.

Fix:

  • The hook reads the module source first and imports only a module that contains ovoscope_intent_cases. Other test modules are not imported early.
  • When that import fails, the hook removes the half-run module from sys.modules, so pytest's import raises and reports the error.

Evidence

Check Before After
Broken import, --import-mode=importlib 0 tests, 0 errors 1 error naming ModuleNotFoundError
Broken import, --import-mode=prepend 1 error 1 error
Broken import in a module that declares ovoscope_intent_cases 0 errors 1 error
Module-level importorskip (existing test) passes passes
Full suite — 812 passed, 25 skipped

The new tests run pytest through pytester. Both importlib cases failed on dev before the fix.

Found in ovos-m2v-pipeline, which sets --import-mode=importlib. A new test module with a missing import collected 0 tests and reported no error. Its suite collects 1099 tests both with and without the ovoscope plugin, so no broken module hides there today. Other repos with the same setup were not checked.

🤖 Generated with Claude Code

With --import-mode=importlib, the collection hook imported every test
module and swallowed a failure. The half-run module stayed in
sys.modules, so pytest's own import returned it with no tests and no
error. The hook now imports only a module whose source declares
ovoscope_intent_cases, and drops a module that fails to import so the
real import reports it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f1280746-4258-40e3-8a72-39c7885ac4d3
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the fix label Oct 22, 2026
@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Reporting for duty! The automated checks have completed. 🎖️

I've aggregated the results of the automated checks for this PR below.

📋 Repo Health

Evaluating the longevity of the project. 🌳

✅ All required files present.

Latest Version: 1.11.2a1

✅ ovoscope/version.py — Version file
✅ README.md — README
✅ LICENSE — License file
✅ pyproject.toml — pyproject.toml
⚠️ setup.py — setup.py
✅ CHANGELOG.md — Changelog
✅ ovoscope/version.py has valid version block markers

🔒 Security (pip-audit)

I've checked the vulnerability database for hits. 🎯

✅ No known vulnerabilities found (134 packages scanned).

🔍 Lint

Just a little bit of automation magic for you. ✨

❌ ruff: issues found in 74 file(s) — see job log
✅ actionlint: 12 workflow file(s), no finding

🏷️ Release Preview

Crystal ball analysis: predicting the next version! 🔮

Current: 1.11.2a1 → Next: 1.11.3a1

Signal Value
Label (none)
PR title fix: report a test module that fails to import
Bump build

✅ PR title follows conventional commit format.


🚀 Release Channel Compatibility

Predicted next version: 1.11.3a1

Channel Status Note Current Constraint
Stable ⚪ Not in channel -
Testing ❌ Too new (must be <1.0.0) ovoscope>=0.7.2,<1.0.0
Alpha ✅ Compatible ovoscope>=1.6.15a1

⚖️ License Check

Scanning for any non-commercial-only restrictions. 💰

✅ No license violations found.

Policy: Apache 2.0 (universal donor). StrongCopyleft / NetworkCopyleft / WeakCopyleft / Other / Error categories fail. MPL allowed.

📊 Coverage

Ensuring the logic is battle-tested. ⚔️

⚠️ 65.7% total coverage

Files below 80% coverage (16 files)
File Coverage Missing lines
ovoscope/golden_worker.py 0.0% 30
ovoscope/simple_listener.py 0.0% 63
ovoscope/version.py 0.0% 5
ovoscope/classic_listener.py 18.2% 117
ovoscope/intent_cases.py 22.3% 153
ovoscope/pytest_plugin.py 47.5% 213
ovoscope/ocp.py 47.9% 61
ovoscope/cli.py 48.3% 140
ovoscope/tts_intelligibility.py 49.0% 102
ovoscope/e2e.py 57.1% 73
ovoscope/listener.py 57.1% 127
ovoscope/voice_loop.py 59.3% 118
ovoscope/media.py 60.3% 96
ovoscope/audio.py 64.4% 126
ovoscope/__init__.py 66.9% 401
ovoscope/media_provider.py 67.6% 23

Full report: download the coverage-report artifact.

🔨 Build Tests

Ensuring the scaffolding is removed and the build is clean. 🧹

✅ All versions pass

Python Build Install Tests pytest
3.10 ✅ ✅ ✅ 812 passed, 25 skipped, 119 warnings in 305.47s (0:05:05)
3.11 ✅ ✅ ✅ 812 passed, 25 skipped, 119 warnings in 304.19s (0:05:04)
3.12 ✅ ✅ ✅ 812 passed, 25 skipped, 119 warnings in 314.75s (0:05:14)
3.13 ✅ ✅ ✅ 812 passed, 25 skipped, 156 warnings in 308.97s (0:05:08)
3.14 ✅ ✅ ✅ 812 passed, 25 skipped, 156 warnings in 324.32s (0:05:24)

An automated hug for your code 🤗

@JarbasAl
JarbasAl marked this pull request as ready for review October 22, 2026 18:10
@JarbasAl
JarbasAl merged commit a7affdb into dev Oct 22, 2026
16 checks passed
@JarbasAl
JarbasAl deleted the fix/broken-test-module-collects-nothing branch October 22, 2026 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants