fix(tests): remove AmbiguousStep conflict in security_pyyaml_dependency_steps
CI / benchmark-regression (push) Has been skipped
CI / helm (push) Successful in 43s
CI / build (push) Successful in 1m7s
CI / lint (push) Successful in 1m16s
CI / quality (push) Successful in 1m45s
CI / security (push) Successful in 1m45s
CI / typecheck (push) Successful in 1m46s
CI / push-validation (push) Successful in 35s
CI / integration_tests (push) Successful in 3m36s
CI / e2e_tests (push) Successful in 3m57s
CI / unit_tests (push) Successful in 5m30s
CI / docker (push) Successful in 1m28s
CI / coverage (push) Successful in 10m44s
CI / status-check (push) Successful in 5s
CI / benchmark-publish (push) Successful in 1h20m49s
CI / benchmark-publish (pull_request) Has been skipped
CI / benchmark-regression (pull_request) Failing after 2m3s
CI / helm (pull_request) Successful in 50s
CI / quality (pull_request) Successful in 1m36s
CI / build (pull_request) Successful in 1m35s
CI / typecheck (pull_request) Successful in 1m23s
CI / unit_tests (pull_request) Successful in 7m14s
CI / e2e_tests (pull_request) Failing after 5m44s
CI / integration_tests (pull_request) Successful in 6m9s
CI / push-validation (pull_request) Successful in 1m18s
CI / lint (pull_request) Successful in 1m12s
CI / security (pull_request) Successful in 1m24s
CI / coverage (pull_request) Has been cancelled
CI / docker (pull_request) Has been cancelled
CI / status-check (pull_request) Has been cancelled

Duplicate step definitions for 'the pyproject.toml file exists at',
'I read the project dependencies from pyproject.toml',
'I attempt to import the module', and 'the import should succeed without
errors' were present in both security_pyyaml_dependency_steps.py and
tdd_a2a_sdk_dependency_steps.py, causing a behave.AmbiguousStep error
that failed the unit_tests CI gate.

Removed the 4 duplicate step definitions from security_pyyaml_dependency_steps.py,
keeping only the 3 PyYAML-specific step definitions. The shared steps are
now exclusively provided by tdd_a2a_sdk_dependency_steps.py.

Also resolved merge conflicts from master in CONTRIBUTORS.md: preserved
all master additions (database resource types entry) alongside the existing
PyYAML upgrade entry.

ISSUES CLOSED: #9055
This commit was merged in pull request #11012.
This commit is contained in:
2026-05-11 07:24:31 +00:00
parent 2f01e7d625
commit b692894c88
@@ -1,39 +1,19 @@
"""Step definitions for PyYAML security dependency verification (#9055)."""
"""Step definitions for PyYAML security dependency verification (#9055).
Note: the shared steps for reading pyproject.toml and verifying importability
are defined in ``tdd_a2a_sdk_dependency_steps.py`` to avoid AmbiguousStep
conflicts. This file contains only the PyYAML-specific step definitions.
"""
from __future__ import annotations
import importlib
import re
from pathlib import Path
from typing import Any
from behave import given, then, when
from behave import then, when
from behave.runner import Context
from packaging.version import parse as parse_version
# Absolute path to the project root (two levels above features/steps/).
# Using an absolute path makes these steps robust against cwd changes that
# can occur when behave-parallel forks worker processes.
_PROJECT_ROOT = Path(__file__).resolve().parent.parent.parent
@given('the pyproject.toml file exists at "{path}"')
def step_pyproject_exists(context: Context, path: str) -> None:
"""Verify pyproject.toml exists at the given path."""
# Resolve relative paths against the project root so the step works
# regardless of the process working directory (e.g. inside parallel workers).
resolved = Path(path) if Path(path).is_absolute() else _PROJECT_ROOT / path
assert resolved.exists(), f"pyproject.toml not found at {resolved}"
context.pyproject_path = resolved
@when("I read the project dependencies from pyproject.toml")
def step_read_project_dependencies(context: Context) -> None:
"""Read the [project.dependencies] list from pyproject.toml."""
content = context.pyproject_path.read_bytes()
data: dict[str, Any] = _load_toml(content)
context.project_dependencies = data.get("project", {}).get("dependencies", [])
@then('the dependency list should include a package matching "{pattern}"')
def step_dependency_matches_pattern(context: Context, pattern: str) -> None:
@@ -85,24 +65,6 @@ def step_pyyaml_minimum_version(context: Context, expected: str) -> None:
)
@when('I attempt to import the "{module_name}" module')
def step_attempt_import(context: Context, module_name: str) -> None:
"""Attempt to import the given module and record the result."""
try:
context.imported_module = importlib.import_module(module_name)
context.import_error = None
except ImportError as exc:
context.imported_module = None
context.import_error = exc
@then("the import should succeed without errors")
def step_import_succeeded(context: Context) -> None:
"""Assert that the previous import attempt succeeded."""
assert context.import_error is None, f"Import failed with: {context.import_error}"
assert context.imported_module is not None, "Module was not imported"
def _flatten_toml_dict(d: dict[Any, Any]) -> dict[str, Any]:
"""Recursively convert a tomlkit dict to a plain Python dict.