Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Tests

- `tests/test_problem_details_extensions.py` imports every module that subclasses an `errors.py` class before it checks each error class's declared defaults, so `CharacterNotFoundError` and `RelaunchFailed` are checked even when the file runs alone ([#1663](https://github.com/ffroliva/gflow-cli/issues/1663)).
- The browser-launch and cookie diagnostic events of `FlowApiClient` (`client.persistent_context_launch`, `client.context_cookie_state`, `client.preread_flow_cookies`, `client.context_cookies_seeded`, `client.har_capture_enabled` and their failure events) have their event names and the field keys and values that triage reads pinned by tests, and the remaining mutmut survivors in the client lifecycle are recorded as equivalent in `docs/DEVELOPMENT.md` (#1266).

## [0.110.0] — 2026-11-30
Expand Down
22 changes: 22 additions & 0 deletions tests/test_problem_details_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from __future__ import annotations

import importlib
import re
from pathlib import Path
from types import SimpleNamespace
Expand Down Expand Up @@ -36,7 +37,22 @@
_DOC = Path(__file__).resolve().parents[1] / "docs" / "ERRORS.md"


_SRC = Path(__file__).resolve().parents[1] / "src" / "gflow_cli"


def _import_error_modules() -> None:
"""Import every module that subclasses an ``errors.py`` class, so the walk below sees
those classes whatever other tests ran first (#1663)."""
names = set(re.findall(r"^class (\w+)\(", (_SRC / "errors.py").read_text("utf-8"), re.M))
base = re.compile(r"^class \w+\((?:\w+\.)?(\w+)\)", re.M)
for path in _SRC.rglob("*.py"):
if path.name != "errors.py" and names & set(base.findall(path.read_text("utf-8"))):
parts = path.relative_to(_SRC).with_suffix("").parts
importlib.import_module(".".join(("gflow_cli", *parts)).removesuffix(".__init__"))


def _all_error_classes() -> list[type[GFlowError]]:
_import_error_modules()
seen: list[type[GFlowError]] = []
stack: list[type[GFlowError]] = [GFlowError]
while stack:
Expand All @@ -59,6 +75,12 @@ def _bare(cls: type[GFlowError], retryable: bool | None) -> GFlowError:
_SUBCLASSES = [c for c in _all_error_classes() if c is not GFlowError]


def test_the_walk_sees_error_classes_defined_outside_errors_py() -> None:
# Run alone, the walk must still see them (#1663): no other test imports their modules.
names = {c.__name__ for c in _SUBCLASSES}
assert {"CharacterNotFoundError", "RelaunchFailed"} <= names


@pytest.mark.parametrize("cls", _SUBCLASSES, ids=lambda c: c.__name__)
def test_every_subclass_declares_its_own_defaults(cls: type[GFlowError]) -> None:
# Own __dict__, not inheritance: a class added without a decision fails here.
Expand Down