Skip to content

test(vendor): a stale warning-class generation makes the snapshot-restore assertion order-dependent #985

Description

@JarryShaw

tests/vendor/test_vendor_snapshot_restore_unit.py holds the same class of defect as #981: a stale
class generation captured before a sibling module purged and reimported pcapkit.

Symptom, under plain unittest with the directory's other modules in the same process:

FAIL: test_a_failure_leaves_the_previous_file_byte_for_byte_intact
      (tests.vendor.test_vendor_snapshot_restore_unit.SnapshotRestoreTests)
AssertionError: VendorRuntimeWarning not triggered

with the warning visibly leaking to stderr one line earlier — it was raised, as a different
VendorRuntimeWarning object than the one assertWarnsRegex is matching against. The module alone
passes: Ran 4 tests in 0.179s ... OK. So it is genuinely order-dependent, not a broken test.

Why it needs its own issue. #984 adds a unittest-ordering CI leg to catch exactly this shape, and
excludes tests/vendor because of this test — so the one job built to see ordering defects is blind
to all 14 modules in that directory, and the finding currently lives only in a comment inside the matrix
entry that excludes it.

The fix is expected to be the same one-line importlib.import_module re-resolution #984 applies in
tests/test_base_class_contract.py — resolve the warning class in setUp rather than at import. Once
it lands, tests/vendor comes out of the exclusion list.

tests/corekit is a separate, pre-existing and documented case (5 identity subtests, per
purge_modules's own docstring) and is not in scope here.

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 2, 2026
  2. added
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 2, 2026
  3. removed
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 2, 2026
  4. 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