fix(test): remove dead after_scenario hooks from step files #729

Open
opened 2026-03-12 13:18:14 +00:00 by CoreRasurae · 0 comments
Member

Metadata

  • Commit Message: fix(test): remove dead after_scenario hooks from step files
  • Branch: fix/m3-dead-after-scenario-hooks

Summary

Two step files define after_scenario() functions that are never invoked by Behave. Behave only calls hooks defined in environment.py, so these functions are dead code and the cleanup they perform is silently skipped.

Background and Context

Identified during the code review of PR #727 (Finding #6 in the APPROVED review by @hurui200320). These are pre-existing issues not introduced by that PR.

Current Behavior

  • features/steps/cli_plan_context_commands_steps.py:599-613 defines an after_scenario() function
  • features/steps/cli_plan_context_steps.py:129-138 defines an after_scenario() function

Neither function is ever called because Behave's hook dispatch only looks in features/environment.py. Any cleanup logic in these functions (engine disposal, temp file removal, etc.) is silently skipped.

Expected Behavior

Either:

  1. Move the cleanup logic into features/environment.py's after_scenario() hook where it will actually be executed, OR
  2. Remove the dead functions if the cleanup they perform is already handled elsewhere (e.g., by environment.py's existing after_scenario)

Acceptance Criteria

  • No after_scenario() functions remain in step files (only in environment.py)
  • Any necessary cleanup logic from the dead functions is preserved in environment.py
  • All existing scenarios still pass
  • No resource leaks introduced

Supporting Information

Subtasks

  • Audit cli_plan_context_commands_steps.py:599-613 — determine if its cleanup logic is needed
  • Audit cli_plan_context_steps.py:129-138 — determine if its cleanup logic is needed
  • Move any required cleanup logic to features/environment.py after_scenario()
  • Remove dead after_scenario() functions from step files
  • Run nox -s unit_tests to verify no regressions

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.
## Metadata - **Commit Message**: `fix(test): remove dead after_scenario hooks from step files` - **Branch**: `fix/m3-dead-after-scenario-hooks` ## Summary Two step files define `after_scenario()` functions that are never invoked by Behave. Behave only calls hooks defined in `environment.py`, so these functions are dead code and the cleanup they perform is silently skipped. ## Background and Context Identified during the code review of PR #727 (Finding #6 in the APPROVED review by @hurui200320). These are pre-existing issues not introduced by that PR. ## Current Behavior - `features/steps/cli_plan_context_commands_steps.py:599-613` defines an `after_scenario()` function - `features/steps/cli_plan_context_steps.py:129-138` defines an `after_scenario()` function Neither function is ever called because Behave's hook dispatch only looks in `features/environment.py`. Any cleanup logic in these functions (engine disposal, temp file removal, etc.) is silently skipped. ## Expected Behavior Either: 1. Move the cleanup logic into `features/environment.py`'s `after_scenario()` hook where it will actually be executed, OR 2. Remove the dead functions if the cleanup they perform is already handled elsewhere (e.g., by `environment.py`'s existing `after_scenario`) ## Acceptance Criteria - [ ] No `after_scenario()` functions remain in step files (only in `environment.py`) - [ ] Any necessary cleanup logic from the dead functions is preserved in `environment.py` - [ ] All existing scenarios still pass - [ ] No resource leaks introduced ## Supporting Information - Identified in: PR #727 Code Review, Finding #6 (APPROVED review) - Review URL: https://git.cleverthis.com/cleveragents/cleveragents-core/pulls/727 - Reviewer: @hurui200320 ## Subtasks - [ ] Audit `cli_plan_context_commands_steps.py:599-613` — determine if its cleanup logic is needed - [ ] Audit `cli_plan_context_steps.py:129-138` — determine if its cleanup logic is needed - [ ] Move any required cleanup logic to `features/environment.py` `after_scenario()` - [ ] Remove dead `after_scenario()` functions from step files - [ ] Run `nox -s unit_tests` to verify no regressions ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done.
freemo added this to the v3.2.0 milestone 2026-03-12 21:01:13 +00:00
freemo self-assigned this 2026-04-02 06:13:51 +00:00
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.

Dependencies

No dependencies set.

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