Files
cleveragents-core/features/steps/main_coverage_complete_steps.py
freemo 4ad51561fc perf(tests): optimize medium-slow BDD features (10-100s tier)
Cap time.sleep and asyncio.sleep globally at 10ms in before_all to
eliminate retry/backoff waits (tenacity wait_fixed, retry_auto_debug
exponential backoff). Save originals as time._original_sleep and
asyncio._original_sleep for tests that need real wall-clock delays
(CircuitBreaker recovery, debounce timers, validation timeouts).

Enhance template-DB patch: add "db." prefix to _SCENARIO_DB_PREFIXES
and check db_path.stat().st_size > 0 so 0-byte auto-created SQLite
files receive the template copy instead of falling through to real
migrations.

Replace subprocess.run CLI invocations with typer.testing.CliRunner
in module_coverage, main_coverage_complete, and coverage_extras step
files, eliminating ~6s Python cold-start overhead per call.

Switch plan_persistence and action_persistence to in-memory SQLite by
default; only cross-restart scenarios use file-based via an explicit
Given step.

Replace MigrationRunner.run_migrations with Base.metadata.create_all
in plan_service_steps for freshly created in-memory engines.

Removed leftover debug comment in environment.py.

Total tier runtime: 565s -> 21s (96% reduction), 20 features all
under 5s behave-internal time.

ISSUES CLOSED: #480
2026-03-02 02:01:27 +00:00

24 lines
781 B
Python

"""Step definitions for complete main module coverage tests."""
from behave import then, when
@when("I run the __main__ module as a script with --version")
def step_run_main_as_script(context):
"""Run the __main__ module via in-process CliRunner (avoids subprocess)."""
from typer.testing import CliRunner
from cleveragents.cli.main import app as main_app
runner = CliRunner()
result = runner.invoke(main_app, ["--version"])
context.result = result
context.exit_code = result.exit_code
context.output = result.output or ""
@then("the version should be displayed")
def step_check_version_displayed(context):
"""Check that the version is displayed."""
assert "CleverAgents" in context.output or "cleveragents" in context.output.lower()