Add dedicated BDD tests for platform.py #2055

Open
opened 2026-04-03 03:43:54 +00:00 by freemo · 1 comment
Owner

Metadata

  • Branch: test/platform-py-bdd-coverage
  • Commit Message: test(platform): add dedicated BDD feature file for platform.py
  • Milestone: v3.6.0
  • Parent Epic: #1678

Background

src/cleveragents/platform.py provides the ensure_cli_importable() helper used in packaged execution contexts. While partial coverage exists across several scattered feature files (consolidated_main_modules.feature, module_coverage.feature, coverage_boost.feature, coverage_extras_steps.py), there is no dedicated, authoritative BDD feature file that comprehensively exercises all branches of platform.py in isolation.

The function has three distinct execution paths that must each be covered:

  1. Happy path — module not yet imported: module_name is absent from sys.modules, so import_module is called and the result is returned.
  2. Cache hit path: module_name is already present in sys.modules, so the cached module is returned immediately without calling import_module.
  3. Import error path: import_module raises ImportError (or ModuleNotFoundError), which must propagate to the caller without suppression.

Without a dedicated feature file, these paths are tested only incidentally, making it easy for future refactors to silently drop coverage below the 97% threshold.

Subtasks

  • Create features/platform.feature with Gherkin scenarios for all three execution paths of ensure_cli_importable()
  • Create or extend features/steps/platform_steps.py with step definitions for the new scenarios, using mocks from features/mocks/ as required
  • Ensure all mocks are placed exclusively in features/mocks/ (no inline mocking in step files beyond unittest.mock patching)
  • Add full type annotations to all step definition functions
  • Run nox -e unit_tests and confirm all new scenarios pass
  • Run nox -e coverage_report and confirm platform.py reaches 100% branch coverage
  • Run nox -e typecheck and confirm no Pyright errors are introduced
  • Run nox -e lint and confirm no linting violations

Definition of Done

  • features/platform.feature exists and covers all three branches of ensure_cli_importable()
  • features/steps/platform_steps.py (or equivalent) contains fully type-annotated step definitions
  • No mocks or test doubles exist outside features/mocks/
  • nox -e unit_tests passes with zero failures
  • nox -e coverage_report reports platform.py at 100% and overall project coverage ≥ 97%
  • nox -e typecheck passes with zero errors
  • nox -e lint passes with zero violations
  • All nox stages pass
  • Coverage >= 97%

Automated by CleverAgents Bot
Supervisor: Unknown | Agent: ca-new-issue-creator

## Metadata - **Branch**: `test/platform-py-bdd-coverage` - **Commit Message**: `test(platform): add dedicated BDD feature file for platform.py` - **Milestone**: v3.6.0 - **Parent Epic**: #1678 ## Background `src/cleveragents/platform.py` provides the `ensure_cli_importable()` helper used in packaged execution contexts. While partial coverage exists across several scattered feature files (`consolidated_main_modules.feature`, `module_coverage.feature`, `coverage_boost.feature`, `coverage_extras_steps.py`), there is no dedicated, authoritative BDD feature file that comprehensively exercises all branches of `platform.py` in isolation. The function has three distinct execution paths that must each be covered: 1. **Happy path — module not yet imported**: `module_name` is absent from `sys.modules`, so `import_module` is called and the result is returned. 2. **Cache hit path**: `module_name` is already present in `sys.modules`, so the cached module is returned immediately without calling `import_module`. 3. **Import error path**: `import_module` raises `ImportError` (or `ModuleNotFoundError`), which must propagate to the caller without suppression. Without a dedicated feature file, these paths are tested only incidentally, making it easy for future refactors to silently drop coverage below the 97% threshold. ## Subtasks - [ ] Create `features/platform.feature` with Gherkin scenarios for all three execution paths of `ensure_cli_importable()` - [ ] Create or extend `features/steps/platform_steps.py` with step definitions for the new scenarios, using mocks from `features/mocks/` as required - [ ] Ensure all mocks are placed exclusively in `features/mocks/` (no inline mocking in step files beyond `unittest.mock` patching) - [ ] Add full type annotations to all step definition functions - [ ] Run `nox -e unit_tests` and confirm all new scenarios pass - [ ] Run `nox -e coverage_report` and confirm `platform.py` reaches 100% branch coverage - [ ] Run `nox -e typecheck` and confirm no Pyright errors are introduced - [ ] Run `nox -e lint` and confirm no linting violations ## Definition of Done - [ ] `features/platform.feature` exists and covers all three branches of `ensure_cli_importable()` - [ ] `features/steps/platform_steps.py` (or equivalent) contains fully type-annotated step definitions - [ ] No mocks or test doubles exist outside `features/mocks/` - [ ] `nox -e unit_tests` passes with zero failures - [ ] `nox -e coverage_report` reports `platform.py` at 100% and overall project coverage ≥ 97% - [ ] `nox -e typecheck` passes with zero errors - [ ] `nox -e lint` passes with zero violations - [ ] All nox stages pass - [ ] Coverage >= 97% --- **Automated by CleverAgents Bot** Supervisor: Unknown | Agent: ca-new-issue-creator
freemo added this to the v3.6.0 milestone 2026-04-03 03:44:01 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: Medium
  • Milestone: v3.6.0
  • MoSCoW: Should Have — BDD tests for platform.py contribute to the 97% coverage requirement

Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: ca-project-owner

Issue triaged by project owner: - **State**: Verified - **Priority**: Medium - **Milestone**: v3.6.0 - **MoSCoW**: Should Have — BDD tests for `platform.py` contribute to the 97% coverage requirement --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
cleveragents/cleveragents-core#2055
No description provided.