Skip to content

test: three modules pass alone but fail together, and pytest reports it green #981

Description

@JarryShaw

Three test modules pass individually and fail when run in one process. pytest does not report the
failure at all
, which is what makes it worth filing rather than just fixing.

Reproduced on main (c49500438), repo venv, PYTHONPATH at the repo root:

tests.test_base_class_contract alone
  -> Ran 7 tests in 1.218s ... OK

tests.protocols.application.test_http_unit + tests.test_base_class_contract
  + tests.const.test_const_str_payload_870_unit, one process, plain unittest
  -> Ran 73 tests in 72.481s ... FAILED (failures=1, errors=3)

pytest over the same three files
  -> 73 passed, 603 subtests passed, exit 0

The failing assertion is RegistrationGateTests.test_user_style_subclass_registers_when_it_opts_in,
at suite='dumpers':

AssertionError: Items in the second set but not the first:
'user_opt_in_dumpers'

So a dumper the test registers under its opt-in keyword is absent from the registry by the time the
assertion runs, once the other two modules have imported first. Four subTests fail in total —
engines, reassembly, traceflow, dumpers.

Two things make this more than a flaky ordering nuisance.

The file's own .. note:: predicts cross-module registry interference, so the mechanism is known; what
is not recorded is that it currently fires. And pytest reports the run fully green — a parent node
reads passed when only its subTests failed, so CI cannot see this. Any suite-wide ordering regression
of this shape is invisible to the checks we run.

Not caused by any open change: I reproduced it at the merge base before the three prose PRs in flight.

Worth deciding separately whether the fix is isolating the registry per module, making the assertion
order-independent, or adding a plain-unittest leg to CI so the class of defect stops being invisible.

Activity

  1. added
    bugIssues reporting a defect (set by the bug report template; a default, not an assessment)
    testPull requests that add or correct tests (test: subject prefix)
    on Oct 1, 2026
  2. JarryShaw commented on Oct 1, 2026

    @JarryShaw
    OwnerAuthor

    wip or blocked?

  3. JarryShaw commented on Oct 1, 2026

    @JarryShaw
    OwnerAuthor

    Neither, by the taxonomy — and that is the honest answer rather than a dodge. wip means an issue
    has a covering pull request; blocked means something checkable is in the way. This has neither:

    covering PR for #981        none  (the #719 excepthook change touches tests/utilities/
                                      but does not fix this; #457 is an unrelated merged one)
    blocker                     none  — nothing is in the way
    still reproduces on main    yes   — Ran 73 tests ... FAILED (failures=1, errors=3)
    

    It is idle, and the reason it is idle is me: I filed it with three candidate approaches and no
    recommendation, which left it waiting on you rather than on work. That was the wrong shape for a defect
    report. So I am picking one and dispatching, which makes the label wip truthfully rather than
    decoratively.

    The approach I am taking, and why it changed since I filed it. The defect found a second instance
    today: tests/utilities/test_decorators.py leaks sys.tracebacklimit on main — it builds a loud
    StructError with no quiet=True and no teardown, and 22 tests pass while leaving the global set. I
    confirmed it still leaks on main right now, with no tearDown or addCleanup in the file.

    Two independent instances makes this systemic rather than incidental, so the per-test fix is not
    enough on its own.
    Both leaks are invisible to pytest, which reports a parent node as passed when
    only its subTests fail — so CI cannot see either one. I am therefore doing both halves: fix the leaking
    teardowns, and add a plain-unittest leg to CI so the class stops being invisible. Fixing the two
    known leaks without that leaves the next one undetectable.

    Labelled wip. The #719 traceback work already carries the test_decorators.py teardown as a
    by-product, so I will scope this to the registry-isolation half and the CI leg to avoid a conflict, and
    say so on the pull request.

  4. added
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 1, 2026
  5. 2 remaining items

  6. JarryShaw commented on Oct 2, 2026

    @JarryShaw
    OwnerAuthor

    Closing — the leftover landed. #988 merged at 15:57:55Z as efc3b08c2, and I verified on main that
    tests/vendor is now in the unittest-ordering matrix: 10 legs, vendor present.

    The whole of this issue is now done, by three merges rather than one:

    Two measurements worth keeping, because they are what justified closing rather than guessing. On current
    main, python -m unittest discover -s tests/vendor gives Ran 118 tests in 83.236s ... OK; as a leg, with the
    five root modules, it is 297 tests in ~104s. And the defect class is structurally absent from that
    directory, not merely unobserved — an AST sweep of all 14 modules, including statements nested in module-level
    try/if/with and in class bodies, found zero module-level pcapkit-reaching imports, so there is no
    import-time binding left for a sibling purge to desync. The only two generation-sensitive assertions resolve
    their class per test.

    Two things deliberately out of scope and still true, so the next reader does not mistake them for
    regressions: tests/corekit stays excluded from the leg — its 5 identity failures are a pre-existing, documented
    limitation recorded in tests/_support.py's purge_modules docstring; and tests/integration stays excluded
    because is_unit_tier rejects all 12 of its modules, so the leg would collect nothing from it.

    One correction recorded against my own work here: I reported mid-investigation that tests/vendor still failed
    on main after #986. It did not — I had measured from a checkout four merges stale, since git fetch updates
    the remote ref and leaves the working tree alone.

  7. removed
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 2, 2026
  8. added this to the 1.5 milestone on Oct 6, 2026
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

    bugIssues reporting a defect (set by the bug report template; a default, not an assessment)testPull requests that add or correct tests (test: subject prefix)

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions