Skip to content

test: spell test_base_class_contract's suffix strip so Python 3.8 runs it (#1699) - #1700

Merged
JarryShaw merged 1 commit into
mainfrom
test/1699-removesuffix-py38
Oct 14, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
test/1699-removesuffix-py38

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

Please follow the guide below

What is the purpose of your pull request?

Tick the commit type your subject line carries.

  • fix — corrects a defect
  • feat — adds a feature
  • perf — changes performance, not behaviour
  • refactor — changes neither behaviour nor performance
  • test — tests only
  • docs — documentation only
  • ci — workflows or build tooling
  • release — bumps the version or rolls up a distribution
  • chore — anything else

Description of your pull request and other information

tests/test_base_class_contract.py:249 stripped .py from each PENDING_ALIAS_PATHS key with str.removesuffix (3.9+). The dict is empty, so the line never ran; its first entry would raise AttributeError on the 3.8 leg. It now reads rel[:-len('.py')] if rel.endswith('.py') else rel, equal to removesuffix('.py') on all 2,311 paths and directory prefixes under pcapkit/ plus edge cases, on 3.9 and 3.14.

With one key patched in (throwaway runner, not committed) and only that test run:

3.8.20 3.9.25 3.14.8
origin/main, key pcapkit/protocols/protocol.py AttributeError: 'str' object has no attribute 'removesuffix' OK OK
this branch, same key OK OK OK
whole module, unpatched, before / after 7 / 7 passed 7 / 7 passed 7 / 7 passed

Key pcapkit/vendor/ gives the same results. No other 3.9+ API in the file: a pattern scan and ast.parse(feature_version=(3, 8)) find none, and the lines 3.8 never executes are docstrings and 3.8-safe calls. Narrow runs only; make test was not run.

Closes #1699

…s it (#1699)

BaseClassAliasTests.test_library_modules_do_not_bind_the_public_name_at_runtime
stripped `.py` from each PENDING_ALIAS_PATHS key with `str.removesuffix`, which
is Python 3.9+. The dict is empty today, so the line never ran; its first entry
would have raised AttributeError on the 3.8 leg. It now reads
`rel[:-len('.py')] if rel.endswith('.py') else rel`, the same result.

With one entry patched in, the test errors on 3.8 before and passes after; the
module is 7 passed, unchanged, on 3.8, 3.9 and 3.14.
@JarryShaw JarryShaw added test Pull requests that add or correct tests (test: subject prefix) review: good-to-go Cross-review at the current head says ready; CI state is separate labels Oct 14, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Verdict: GOOD TO GO at 728a2fb16. A Sonnet cross-review compared the new spelling with removesuffix('.py') on 1,434 inputs, on 3.9 and 3.14, and found no mismatches. With one entry patched into PENDING_ALIAS_PATHS, the base raises AttributeError on 3.8 and the head passes; 3.9 and 3.14 are unchanged. Unpatched, the module runs 7 tests on 3.8, 3.9 and 3.14 both before and after.

@JarryShaw JarryShaw added test Pull requests that add or correct tests (test: subject prefix) review: good-to-go Cross-review at the current head says ready; CI state is separate labels Oct 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage: 89.47% (unit tier, Python 3.15, 728a2fb16, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 3 20 3 95.16%
pcapkit/const 18858 954 2366 868 91.06%
pcapkit/corekit 2366 67 760 35 96.48%
pcapkit/dumpkit 275 3 100 3 98.40%
pcapkit/foundation 3035 151 1076 34 94.28%
pcapkit/interface 138 7 52 5 93.68%
pcapkit/protocols 17166 226 4580 190 98.07%
pcapkit/toolkit 1437 279 592 5 78.12%
pcapkit/utilities 494 4 146 4 98.75%
pcapkit/vendor 4417 2342 1010 157 43.38%

Per-file detail: the coverage-html artifact of this run.

@JarryShaw
JarryShaw merged commit 24d8f23 into main Oct 14, 2026
54 checks passed
@JarryShaw
JarryShaw deleted the test/1699-removesuffix-py38 branch October 14, 2026 02:42
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Oct 14, 2026
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 14, 2026
@JarryShaw JarryShaw added this to the PyPCAPKit v1.5 milestone Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test Pull requests that add or correct tests (test: subject prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

test: test_base_class_contract.py calls str.removesuffix, which Python 3.8 lacks, on a path that runs once PENDING_ALIAS_PATHS is non-empty

1 participant