Skip to content

test: key the is_manufactured() exemption on the name shape, not on two file paths #879

Closed

Description

@JarryShaw

Follow-up from #878's review. That PR exempts two files from test_const_enum_no_mint.py's is_manufactured() sweep so the preserved hex-suffixed names pass:

HEX_SUFFIXED_NAME_EXEMPT_PATHS = frozenset({...})   # :1160, consulted at :1290

The exemption is keyed on file path, so it is shape-blind inside those two files. Measured — mutating one branch in a scratch copy of f210ddc71, asserting the line's content first:

mutated const/reg/ethertype.py:540 to:
    return cls._unregistered_member(value, 'Xyplex_%d' % value)
UnregisteredMemberNameIsBareTests -> run=1 failures=0 errors=0

'Xyplex_%d' % value is exactly the value-derived shape the predicate exists to flag, and the sweep passes because exempt_hits stays at 53.

Not a defect in #878, and deliberately not blocked on there: all 53 exempted sites share one identical suffix expression, 0 manufactured names outside those two files are exempted, and the harm is_manufactured() names — a __members__ collision between minted members — cannot occur at all now, because _unregistered_member is three statements that touch neither _member_map_ nor _value2member_map_. So the widened area is structurally unable to cause the defect.

The fix: key the exemption on the name-expression shape (… _0x%s' % hex(value)[2:].upper().zfill(4)) rather than on two paths. That needs no path list, covers exactly the 53 intended sites, and would fail the mutant above. Keep assertEqual(exempt_hits, 53) as the bound either way.

Worth doing while the reasoning is fresh; it is a test-only change.

Activity

  1. added
    testPull requests that add or correct tests (test: subject prefix)
    refactorRestructuring for its own sake — neither a fix nor a new capability (refactor: prefix)
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Sep 28, 2026
  2. JarryShaw commented on Sep 28, 2026

    @JarryShaw
    OwnerAuthor

    PR is up: #881 — #881, head df62008ce, one commit, one file.

    Stacked on #878 (base fix/775-ethertype-socket-no-mint), since the code this guards exists only there; GitHub retargets it to main once #878 merges, and it must not merge first.

    HEX_SUFFIXED_NAME_EXEMPT_PATHS is gone. The exemption now matches the name-expression shape by AST structural comparison against hex(value)[2:].upper().zfill(4), which hits exactly the 53 intended sites — every one shares that suffix verbatim, and no other call site in pcapkit/const/ contains 0x%s at all.

    I verified the fix rather than taking the report: mutating const/reg/ethertype.py:540 to 'Xyplex_%d' % value — the mutation that passed before — now fails with AssertionError: 52 != 53 : expected exactly 53 hex-suffixed-name exemptions to fire, found 52. Unmutated the file is 69/0/0, and a value-derived name in an unrelated file (const/arp/hardware.py:163) is still flagged.

  3. removed
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Sep 28, 2026
  4. added this to the 1.5 milestone on Oct 6, 2026
  5. moved this to Done in PyPCAPKiton 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

    refactorRestructuring for its own sake — neither a fix nor a new capability (refactor: prefix)testPull requests that add or correct tests (test: subject prefix)

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions