Skip to content

Floating-box journey closes its fixture-owned page early #5172

Closed

Description

@leaf-agent

The scheduled run 41432142330 records this failing boundary. This report supplies CI evidence; it has not reproduced the failure on current main or established its cause.

Earlier test-name matches are #4237, #4926, #186. Compare their deciding diagnostics and repairs before claiming recurrence; a name match alone is not shared ownership.

Reconcile against current main and active repair work, reproduce the focused boundary, and fix the highest incorrect owner while preserving the originating change’s intent and the user behavior. Reuse an existing owner when reproduction proves a shared mechanism. Follow normal review and landing gates.

tests.journeys.test_interact_layer::test_the_resources_a_fixture_owns_are_taken_from_that_fixture — Linux
def test_the_resources_a_fixture_owns_are_taken_from_that_fixture():
        """Each of these has one owner in the suite, and the owner is what ends it.
    
        A process, a browser, and a directory short enough to hold a socket: what a test
        gets by asking for the fixture is a teardown, and what it gets by calling the
        primitive itself is a resource the run has no way to take back — a server still
        serving after the test that started it, a browser held for the rest of the
        worker, a directory under a root neither sweep walks. A fixture cannot stop a
        test making its own, so the call is read for here instead, which is the only
        place the rule can be enforced rather than written down.
    
        A new exception is a line in this list naming the file it belongs to and the
        reason, not a call that quietly joins the others.
    
        The end of the loan is read for too. A page or context the `browser` fixture
        made is closed by that fixture, after it has read what the page reported; a
        close where the test ends with it does the same work a step early, and the
        reading it cuts short is its own. The exception is a page that keeps making
        the fault its test is about, where the consume has to follow a close of its own
        (tests/AGENTS.md, "Browser errors").
        """
        closes_to_stop_a_repeating_fault = {
            "test_a_website_session_reference_survives_a_failed_first_read",
            "test_a_malformed_first_state_keeps_interaction_unresolved",
        }
        # What hands a test something the browser fixture will close: the fixtures built
        # on it, and `opened_tab`, whose tab is made readable and so reports into the
        # collector that fixture reads.
        lending = {"browser", "iphone", "held_events", "one_user", "opened_tab"}
        owners = {
            "Popen": ("spawn", {"conftest.py"}),
            "mkdtemp": ("socket_dir", {"interact_support.py"}),
            # The cached Codex schema helper in conftest.py closes its output
            # directory with a context manager before returning the schemas.
            "TemporaryDirectory": ("socket_dir", {"interact_support.py", "conftest.py"}),
            "launch": ("browser, iphone", {"conftest.py"}),
        }
        bypassed = []
        for path in sorted((ROOT / "tests").rglob("*.py")):
            named = path.relative_to(ROOT / "tests").as_posix()
            tree = ast.parse(path.read_text(encoding="utf-8"))
            for node in ast.walk(tree):
                called = (
                    node.func.attr
                    if isinstance(node, ast.Call) and isinstance(node.func, ast.Attribute)
                    else None
                )
                if (
                    isinstance(node, ast.Call)
                    and called in owners
                    and named not in owners[called][1]
                ):
                    owner = owners[called][0]
                    bypassed.append(f"{named}:{node.lineno} {called} — {owner} owns it")
            for function in (n for n in ast.walk(tree) if isinstance(n, ast.FunctionDef)):
                if function.name in closes_to_stop_a_repeating_fault:
                    continue
                # A fixture's own teardown is the owner ending what it lent. Read what
                # the decorator calls, not its whole text, which also carries a
                # `parametrize` whose ids can say "fixture".
                if any(
                    ast.unparse(d).split("(")[0].endswith("fixture")
                    for d in function.decorator_list
                ):
                    continue
                # What the fixture owns is what came from it, however far the value
                # travelled and whatever the function was handed it as:
                # `host, app = open_snapshot_app(browser, page_dir)` hands back a page
                # as surely as `browser.new_page()` does, `browser, held = held_events`
                # hands over the browser itself, and `for tab in (first, second)` walks
                # pages. A list of the spellings that count would read some and miss
                # the next, so the names are followed until nothing new is reached.
                bindings = []
                for node in ast.walk(function):
                    if isinstance(node, ast.Assign):
                        bindings.append((node.value, node.targets))
                    elif isinstance(node, ast.For):
                        bindings.append((node.iter, [node.target]))
                    elif isinstance(node, ast.With):
                        bindings += [
                            (item.context_expr, [item.optional_vars])
                            for item in node.items
                            if item.optional_vars is not None
                        ]
                lent = set(lending)
                while True:
                    reached = {
                        name.id
                        for value, targets in bindings
                        if lent & {n.id for n in ast.walk(value) if isinstance(n, ast.Name)}
                        for target in targets
                        for name in ast.walk(target)
                        if isinstance(name, ast.Name)
                    }
                    if reached <= lent:
                        break
                    lent |= reached
                # Only where the test is finished with the page: anywhere in a `finally`,
                # which is the end of the block the page was used in, and the function's
                # last line, followed down through a block it ends on. A close written
                # anywhere else is the gesture under test — a second tab shut to show
                # what the first one still holds — and the assertions after it are what
                # read it.
                endings = [
                    statement
                    for node in ast.walk(function)
                    if isinstance(node, ast.Try)
                    for final in node.finalbody
                    for statement in ast.walk(final)
                ]
                last = function.body[-1]
                while isinstance(last, (ast.For, ast.If, ast.With)):
                    last = last.body[-1]
                endings.append(last)
                for node in endings:
                    if not isinstance(node, ast.Expr):
                        continue
                    ending = ast.unparse(node)
                    if ending.endswith(".close()") and ending[: -len(".close()")] in lent:
                        bypassed.append(
                            f"{named}:{node.lineno} {ending} — the browser fixture does"
                        )
>       assert not bypassed, bypassed
E       AssertionError: ['journeys/test_floating_box_motion.py:221 page.close() — the browser fixture does', 'journeys/test_floating_box_motion.py:221 page.close() — the browser fixture does']
E       assert not ['journeys/test_floating_box_motion.py:221 page.close() — the browser fixture does', 'journeys/test_floating_box_motion.py:221 page.close() — the browser fixture does']

tests/journeys/test_interact_layer.py:285: AssertionError

Full diagnostics are in the run’s pytest-results-* JUnit artifacts.

Cause of a failure tracked in #4225.

Activity

  1. added
    tend-ci-cause
    on Nov 3, 2026
  2. leaf-agent commented on Nov 3, 2026

    @leaf-agent
    CollaboratorAuthor

    Fixed by #5216, now merged. The floating-box journey closed each Hypothesis example's page in its own finally. The browser fixture judges every still-open page's watches at teardown (judge_watches skips a closed page), so that judgement was skipped for every example. The same guard also flagged test_a_frame_of_another_live_leaf_page_is_checked_on_its_own in tests/browser/test_render_gate.py on current main. Both tests now leave their pages for the fixture to close.

    The guard failed locally on main naming both files and passes with the change. The gate test passes. The journey passes on Chromium and Firefox with all 22 example pages per engine left open until teardown. The PR's CI was green at its head.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    tend-ci-cause

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions