From a4d12fbffe5d271db463d33373c361b831de5cca Mon Sep 17 00:00:00 2001 From: Jarry Shaw Date: Tue, 6 Oct 2026 09:30:42 -0400 Subject: [PATCH] docs(tests): tighten the foundation and corekit test prose from the post-sweep merges (#719) --- tests/corekit/test_fields_collections.py | 6 +++--- tests/corekit/test_fields_field.py | 9 ++++----- tests/foundation/registry/test_foundation.py | 4 ++-- tests/foundation/test_extraction.py | 9 ++++----- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/tests/corekit/test_fields_collections.py b/tests/corekit/test_fields_collections.py index 2bd7e48bc8..4ad4a04f7b 100644 --- a/tests/corekit/test_fields_collections.py +++ b/tests/corekit/test_fields_collections.py @@ -302,9 +302,9 @@ def subclasses(cls: 'Any') -> 'Any': fell_back = [] # type: list[str] total = 0 for cls in set(subclasses(Schema)): - # Only this package's own declarations: a test that builds a schema - # of its own leaves it among the subclasses for as long as the - # import lives, and that is no longer one import per test (#1065). + # Only this package's own declarations: a schema a test builds for + # itself stays among the subclasses for as long as the import lives, + # and the whole class shares one import (#1065). if cls.__module__.split('.')[0] != 'pcapkit': continue for name, field in getattr(cls, '__fields__', {}).items(): diff --git a/tests/corekit/test_fields_field.py b/tests/corekit/test_fields_field.py index ae2b6ae5a8..232aa2a808 100644 --- a/tests/corekit/test_fields_field.py +++ b/tests/corekit/test_fields_field.py @@ -236,11 +236,10 @@ def setUp(self) -> None: self.FieldValueError = FieldValueError self.ceiling = field_module._MAX_ZERO_PAD_LENGTH - # The ledger is cumulative per context, so whatever ran earlier in this - # process -- a sibling class, another module -- has already earned - # allowance against it. Start every test from the unset default, as a - # freshly imported module would, rather than relying on a re-import per - # test to do it (GitHub issue #1065). + # The ledger is cumulative per context, and this class's tests share one + # import of the module, so an earlier test has already earned allowance + # against it. Start every test from the unset default, as a freshly + # imported module would (GitHub issue #1065). token = field_module._zero_pad_ledger.set(None) self.addCleanup(field_module._zero_pad_ledger.reset, token) diff --git a/tests/foundation/registry/test_foundation.py b/tests/foundation/registry/test_foundation.py index f886c7da80..6a2bc46ccc 100644 --- a/tests/foundation/registry/test_foundation.py +++ b/tests/foundation/registry/test_foundation.py @@ -179,8 +179,8 @@ def test_registration_accepts_pcapkit_own_builtin_classes(self) -> None: # path instead of the public wrappers. The subject classes and the read-back # are unchanged. # - # NOTE: imported inside the test because ``setUp`` swaps in a fresh ``pcapkit`` in - # ``sys.modules``, which is why every sibling test imports locally too. + # NOTE: imported inside the test because ``setUp`` puts the class's own ``pcapkit`` + # import in ``sys.modules``, which is why every sibling test imports locally too. # ``Extractor`` is needed by name here so the registries can be read back. from pcapkit.foundation.engines.pcap import PCAP as PCAP_Engine from pcapkit.foundation.extraction import Extractor diff --git a/tests/foundation/test_extraction.py b/tests/foundation/test_extraction.py index e06510906b..a98b58f457 100644 --- a/tests/foundation/test_extraction.py +++ b/tests/foundation/test_extraction.py @@ -89,11 +89,10 @@ def setUp(self) -> None: # Several tests here register into the four registries for real -- # overwriting ``json``, ``dpkt``, ``ipv4`` and ``tcp`` with stand-ins, - # or adding ``unit-*`` names -- so each table is put back in place - # afterwards. A fresh import per test used to do that implicitly; without - # it, a later extraction ran the stand-in engine and hung, and - # :mod:`tests.interface.test_core` found engines it has no constant for - # (GitHub issue #1065). + # or adding ``unit-*`` names -- and the class shares one import, so each + # table is put back afterwards. Without that, a later extraction ran the + # stand-in engine and hung, and :mod:`tests.interface.test_core` found + # engines it has no constant for (GitHub issue #1065). for table in (Extractor.__output__, Extractor.__engine__, Extractor.__reassembly__, Extractor.__traceflow__): self.addCleanup(lambda table=table, saved=dict(table): (table.clear(), table.update(saved)))