From 79ac0ed7392c3ba7af857c317f0c4354b62ff07f Mon Sep 17 00:00:00 2001 From: Jarry Shaw Date: Thu, 15 Oct 2026 19:00:32 -0400 Subject: [PATCH] docs(tests): second whole-repo pass over tests (#1103) Prose only: with every string expression statement blanked, each changed module's AST is identical to origin/main's. - RFC 959: the case-folding rule sits in Section 5.3, not 4.1, in the #896 and #903 modules (RFC text, line 2559). - Counts: the release-gate mutation table's #966 block is six rows, not five; the comment now sums to the table's 21. - pack(): the GH-452 HTTP docstring describes pack() as it is after #1791, building on _packing_target(); the MPTCP stale-flags case says make, which it calls. - Line references re-measured against origin/main: 23 pointers in 14 files, into protocol.py, frame.py, field.py, byteorder.py, the five UnsupportedCall sites, tcp.py, ipv6.py, extension_header.py, the pcapng schema, apptype.py and vendor/__main__.py. Refs #1103 --- tests/conftest.py | 2 +- tests/const/test_const_ftp_featcode_case_903_unit.py | 2 +- .../const/test_const_method_case_sensitive_896_unit.py | 4 ++-- tests/corekit/test_fields_copy_dispatch_unit.py | 4 ++-- tests/corekit/test_fields_misc_packet_context.py | 2 +- tests/project/test_module_isolation.py | 2 +- tests/project/test_release_gates.py | 2 +- tests/project/test_rfc_anchor_fragments.py | 2 +- tests/protocols/application/test_http_unit.py | 10 ++++++---- tests/protocols/internet/test_ipv6_ext_unit.py | 2 +- tests/protocols/internet/test_mh_unit.py | 2 +- tests/protocols/misc/test_pcapng_unit.py | 2 +- .../schema/test_schema_metaclass_abc_cache_unit.py | 2 +- .../protocols/test_construction_keyword_check_unit.py | 8 ++++---- .../test_tcp_mptcp_join_flag_ordering_unit.py | 4 ++-- tests/test_support_helpers.py | 2 +- tests/vendor/test_crawler_reachability_unit.py | 4 ++-- 17 files changed, 29 insertions(+), 27 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index b3b4afb50d..c001ddec06 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -244,7 +244,7 @@ def restore_module_table() -> 'Iterator[None]': :class:`~typing.Generic` stayed bound after the test that installed it, and the next test to import :mod:`pcapkit` died on ``TypeError: type 'ProtocolBase' is not subscriptable`` at - ``pcapkit/protocols/misc/pcap/frame.py:61`` -- twelve tests in + ``pcapkit/protocols/misc/pcap/frame.py:69`` -- twelve tests in :mod:`tests.project`, and only when the polluting file happened to be collected first. Three separate files turned out to leak this way, one of which -- :mod:`tests.cli.test_main` -- did not import :mod:`tests._support` diff --git a/tests/const/test_const_ftp_featcode_case_903_unit.py b/tests/const/test_const_ftp_featcode_case_903_unit.py index 2c6b67acf9..b52849db77 100644 --- a/tests/const/test_const_ftp_featcode_case_903_unit.py +++ b/tests/const/test_const_ftp_featcode_case_903_unit.py @@ -280,7 +280,7 @@ def test_tls_key_label_stays_case_sensitive(self) -> 'None': def test_command_keeps_its_own_rfc_959_fold(self) -> 'None': """:class:`~pcapkit.const.ftp.command.Command` shares this module and - folds for a different reason -- RFC 959 Section 4.1's *"Upper and + folds for a different reason -- RFC 959 Section 5.3's *"Upper and lower case alphabetic characters are to be treated identically"* -- so it must be unaffected by the sibling class changing.""" self.assertIs(Command.get('RETR'), Command.RETR) # type: ignore[attr-defined] diff --git a/tests/const/test_const_method_case_sensitive_896_unit.py b/tests/const/test_const_method_case_sensitive_896_unit.py index 75dcc6e518..cc00385b6d 100644 --- a/tests/const/test_const_method_case_sensitive_896_unit.py +++ b/tests/const/test_const_method_case_sensitive_896_unit.py @@ -15,7 +15,7 @@ non-standardised method from the registered ``GET`` -- conflating the two was the defect. Contrast :class:`~pcapkit.const.ftp.command.Command`'s own equivalent override, which stays case-insensitive deliberately: RFC 959 -Section 4.1 says FTP's four-letter command codes *are* to be treated +Section 5.3 says FTP's four-letter command codes *are* to be treated identically regardless of case, so ``Command.get`` is untouched by this issue and is repinned below (:meth:`MethodGetCaseSensitivityTests. test_command_get_stays_case_insensitive`) so a future change cannot quietly @@ -212,7 +212,7 @@ def test_unregistered_member_preserves_the_callers_casing(self) -> None: def test_command_get_stays_case_insensitive(self) -> None: """The registry #896 explicitly leaves alone. - RFC 959 Section 4.1: FTP command codes are to be treated + RFC 959 Section 5.3: FTP command codes are to be treated identically regardless of case, so :meth:`~pcapkit.const.ftp.command.Command.get` keeps folding case -- pinned here so a future edit to the sibling ``Method`` fix cannot diff --git a/tests/corekit/test_fields_copy_dispatch_unit.py b/tests/corekit/test_fields_copy_dispatch_unit.py index 29fc88a482..45ec9b4cd3 100644 --- a/tests/corekit/test_fields_copy_dispatch_unit.py +++ b/tests/corekit/test_fields_copy_dispatch_unit.py @@ -85,7 +85,7 @@ def assertCallReachesCopyDunderOnly(self, field: 'FieldBase[Any]') -> None: self.assertIsInstance(new_field, type(field)) def test_field_base_call_field_py_294(self) -> None: - """:meth:`FieldBase.__call__` (``field.py:281``), reached via :class:`NoValueField`. + """:meth:`FieldBase.__call__` (``field.py:274``), reached via :class:`NoValueField`. :class:`~pcapkit.corekit.fields.misc.NoValueField` is the one concrete class in this package that never overrides ``__call__``, so it is the @@ -98,7 +98,7 @@ class in this package that never overrides ``__call__``, so it is the self.assertCallReachesCopyDunderOnly(NoValueField()) def test_field_call_field_py_579(self) -> None: - """:meth:`Field.__call__` (``field.py:581``).""" + """:meth:`Field.__call__` (``field.py:580``).""" from pcapkit.corekit.fields.field import Field self.assertCallReachesCopyDunderOnly(Field(length=4)) diff --git a/tests/corekit/test_fields_misc_packet_context.py b/tests/corekit/test_fields_misc_packet_context.py index 8635ee3425..a53d6e8bdd 100644 --- a/tests/corekit/test_fields_misc_packet_context.py +++ b/tests/corekit/test_fields_misc_packet_context.py @@ -179,7 +179,7 @@ def test_nested_schema_reads_enclosing_field_by_name_and_does_not_leak_writes(se def test_pcapng_byteorder_consumer_still_works_with_both_shapes(self) -> None: """The one existing, hand-rolled ``__packet__`` fallback is unaffected. - ``packet_byteorder`` (``pcapkit/corekit/fields/byteorder.py:28``) + ``packet_byteorder`` (``pcapkit/corekit/fields/byteorder.py:33``) is called both with a plain dict built by hand -- as several tests and :func:`~pcapkit.foundation.engines.pcapng` construct -- and with what ``SchemaField`` now actually builds. Both must keep working, and diff --git a/tests/project/test_module_isolation.py b/tests/project/test_module_isolation.py index 9f46905653..02e64ab678 100644 --- a/tests/project/test_module_isolation.py +++ b/tests/project/test_module_isolation.py @@ -5,7 +5,7 @@ three in the opposite order gave ``17 passed``. The cause was a test that bound a non-generic ``ProtocolBase`` stand-in into :data:`sys.modules` and finished without removing it, so the next test to import :mod:`pcapkit` died at -``pcapkit/protocols/misc/pcap/frame.py:61`` with ``TypeError: type 'ProtocolBase' +``pcapkit/protocols/misc/pcap/frame.py:69`` with ``TypeError: type 'ProtocolBase' is not subscriptable``. The tests here run :program:`pytest` in a subprocess over the exact selections diff --git a/tests/project/test_release_gates.py b/tests/project/test_release_gates.py index da9621c58e..3b4c4aa920 100644 --- a/tests/project/test_release_gates.py +++ b/tests/project/test_release_gates.py @@ -2722,7 +2722,7 @@ class TestGateMutationsChangeTheTruthTable(WorkflowMixin, unittest.TestCase): #: mutations have to be the *small* edits a review round produces -- a #: regenerated condition would differ in ways nobody would have typed. #: - #: The first eight are the mutations #962 names; the next five are this + #: The first eight are the mutations #962 names; the next six are this #: module's own, covering the clauses the issue only points at -- the #: publishing predecessors' equality pair, the ``startsWith`` #: short-circuit, and reading somebody else's evidence. The ``!= 'true'`` diff --git a/tests/project/test_rfc_anchor_fragments.py b/tests/project/test_rfc_anchor_fragments.py index ae0352636a..4e56785ae4 100644 --- a/tests/project/test_rfc_anchor_fragments.py +++ b/tests/project/test_rfc_anchor_fragments.py @@ -41,7 +41,7 @@ test exists to catch, the same mistake as the allowlist above one layer down. The generators that produce them, :file:`pcapkit/vendor/tcp/mp_tcp_option.py:59` and -:file:`pcapkit/vendor/reg/apptype/apptype.py:1148` (both parsing IANA's +:file:`pcapkit/vendor/reg/apptype/apptype.py:1169` (both parsing IANA's ``RFC8684, Section 3.1`` with the same ``re.fullmatch(r'RFC(?P\\d+)(, Section (?P.*?))?', ...)``, which discards the literal word ``Section`` and keeps only the number), are fixed to emit ``#section-{sec}``, and the ten diff --git a/tests/protocols/application/test_http_unit.py b/tests/protocols/application/test_http_unit.py index 722c1fa4dd..7981a5db89 100644 --- a/tests/protocols/application/test_http_unit.py +++ b/tests/protocols/application/test_http_unit.py @@ -213,10 +213,12 @@ def test_http_construction_reaches_the_versioned_make_callee(self) -> None: ``protocol.make(**kwargs)`` dispatch this issue is actually about. The real, supported entry point is construction: - :meth:`ProtocolBase.__init__` (``protocol.py:1146``, the ``**kwargs``- - only overload at ``:1144``) calls ``self.pack(**kwargs)`` when built - with no ``file``, and :meth:`ProtocolBase.pack` (``protocol.py:750``) - is ``self.__header__ = self.make(**kwargs)`` -- a *bound* call on the + :meth:`ProtocolBase.__init__` (``protocol.py:1203``, the ``**kwargs``- + only overload at ``:1201``) calls ``self.pack(**kwargs)``, through + :meth:`~ProtocolBase.__post_init__`, when built with no ``file``, and + :meth:`ProtocolBase.pack` (``protocol.py:761``) calls + ``target.make(**kwargs)`` on :meth:`~ProtocolBase._packing_target`, + which while constructing is the instance itself -- a *bound* call on the outer ``HTTP`` instance, which is what actually reaches the inner, previously-unbound ``protocol.make(**kwargs)``. So the reachable reproduction is ``HTTP(version=1, ...)``, not ``HTTP.make(...)``: diff --git a/tests/protocols/internet/test_ipv6_ext_unit.py b/tests/protocols/internet/test_ipv6_ext_unit.py index d206b254e5..4c22fda020 100644 --- a/tests/protocols/internet/test_ipv6_ext_unit.py +++ b/tests/protocols/internet/test_ipv6_ext_unit.py @@ -576,7 +576,7 @@ def test_every_subclass_index_returns_a_real_transtype(self) -> None: def test_every_subclass_alias_survives_the_packet_dict_key_computation(self) -> None: """:meth:`IPv6._decode_next_layer ` keys its - packet dict by ``alias.lstrip('IPv6-').lower()`` (``ipv6.py:436``, in ``_exthdr_key``). + packet dict by ``alias.lstrip('IPv6-').lower()`` (``ipv6.py:455``, in ``_exthdr_key``). :meth:`str.lstrip` strips a character *set*, so the hyphen in ``IPv6-Route``/``IPv6-Frag``/``IPv6-Opts`` is what lets ``IPv6`` fall away cleanly, where the underscore of a class-name default like diff --git a/tests/protocols/internet/test_mh_unit.py b/tests/protocols/internet/test_mh_unit.py index 8fbc307b42..2b5fe3e85f 100644 --- a/tests/protocols/internet/test_mh_unit.py +++ b/tests/protocols/internet/test_mh_unit.py @@ -1853,7 +1853,7 @@ def wrap_in_ipv4(mh_payload: bytes) -> IPv4: with self.subTest('over IPv6, the raise now costs only the MH slot (GitHub issue #891)'): # Mobility Header is *also* one of IPv6's own chained extension # headers (``Enum_ExtensionHeader.Mobility_Header``, value 135 -- - # ``pcapkit/const/ipv6/extension_header.py:42``), so IPv6 never + # ``pcapkit/const/ipv6/extension_header.py:49``), so IPv6 never # reaches the fallback through the base ``_import_next_layer`` at # all -- it walks its own ``@beholder``-decorated override # (``pcapkit/protocols/internet/ipv6.py:_import_next_layer``). diff --git a/tests/protocols/misc/test_pcapng_unit.py b/tests/protocols/misc/test_pcapng_unit.py index d343ee129c..a5a5243026 100644 --- a/tests/protocols/misc/test_pcapng_unit.py +++ b/tests/protocols/misc/test_pcapng_unit.py @@ -1414,7 +1414,7 @@ def test_tls_key_label_tracks_rfc_9850_plus_documented_rsa_exception(self) -> No # Every member's value pinned exactly -- this is a value-matched # registry (``TLSKeyLabel(label.upper())`` at - # pcapkit/protocols/schema/misc/pcapng.py:2243), so the value, not + # pcapkit/protocols/schema/misc/pcapng.py:2249), so the value, not # merely the name, is what callers depend on. for name in expected: with self.subTest(name=name): diff --git a/tests/protocols/schema/test_schema_metaclass_abc_cache_unit.py b/tests/protocols/schema/test_schema_metaclass_abc_cache_unit.py index 6649957c4f..9f20c72c2a 100644 --- a/tests/protocols/schema/test_schema_metaclass_abc_cache_unit.py +++ b/tests/protocols/schema/test_schema_metaclass_abc_cache_unit.py @@ -241,7 +241,7 @@ def test_the_pcapng_1248_symptom_no_longer_reproduces(self) -> None: :meth:`NameResolutionBlock.post_process ` asks ``isinstance(record, (IPv4Record, IPv6Record))`` at - :file:`pcapkit/protocols/schema/misc/pcapng.py:1870` and then reads + :file:`pcapkit/protocols/schema/misc/pcapng.py:1876` and then reads ``record.names``. Before #439 was fixed, every schema class shared one ``_abc_impl``, so that question answered ``True`` for the block's *terminating* ``EndRecord`` -- which has no ``names`` -- provided diff --git a/tests/protocols/test_construction_keyword_check_unit.py b/tests/protocols/test_construction_keyword_check_unit.py index 613f485c7e..1c5e555775 100644 --- a/tests/protocols/test_construction_keyword_check_unit.py +++ b/tests/protocols/test_construction_keyword_check_unit.py @@ -289,10 +289,10 @@ def test_the_exception_is_the_one_the_library_already_uses(self) -> None: Not a new exception type: the library already answers "you passed a keyword I do not accept" with :exc:`~pcapkit.utilities.exceptions.UnsupportedCall`, in five places with - this exact message shape -- ``protocol.py:1412``, - ``dumpkit/common.py:168``, ``foundation/reassembly/reassembly.py:587``, - ``foundation/engines/engine.py:314`` and - ``foundation/traceflow/traceflow.py:555``. Reusing it keeps one answer to + this exact message shape -- ``protocol.py:1469``, + ``dumpkit/common.py:169``, ``foundation/reassembly/reassembly.py:594``, + ``foundation/engines/engine.py:321`` and + ``foundation/traceflow/traceflow.py:563``. Reusing it keeps one answer to one question rather than adding a second. The honest caveat, recorded so it is a decision rather than an oversight: diff --git a/tests/protocols/transport/test_tcp_mptcp_join_flag_ordering_unit.py b/tests/protocols/transport/test_tcp_mptcp_join_flag_ordering_unit.py index 2990cbbe3e..6253404aa0 100644 --- a/tests/protocols/transport/test_tcp_mptcp_join_flag_ordering_unit.py +++ b/tests/protocols/transport/test_tcp_mptcp_join_flag_ordering_unit.py @@ -27,7 +27,7 @@ The parse path has the identical pair of branches in ``_read_mptcp_join`` and is fine, because :meth:`~pcapkit.protocols.transport.tcp.TCP.read` assigns ``self._flags`` at -``tcp.py:510``, before it parses the options at ``tcp.py:530``. Only the make path was +``tcp.py:535``, before it parses the options at ``tcp.py:555``. Only the make path was inverted. The fix is the hoist: the ``flags`` dict and the ``_flag`` accumulation move above the @@ -552,7 +552,7 @@ def test_make_re_derives_the_flags_on_every_call(self) -> None: Adding an ``options`` argument would not turn this into a discriminator, which is worth recording since it is the obvious thing to try. Pre-fix, ``make`` assigned - ``self._flags`` *after* building the options -- so by the time ``pack`` returned, + ``self._flags`` *after* building the options -- so by the time ``make`` returned, the attribute held the new call's flags either way, and only the option octets built in between were wrong. The assertion that separates the two trees is therefore on those octets, and diff --git a/tests/test_support_helpers.py b/tests/test_support_helpers.py index 43c240c956..3713f7ac88 100644 --- a/tests/test_support_helpers.py +++ b/tests/test_support_helpers.py @@ -497,7 +497,7 @@ def test_protochain_leaves_no_fake_protocol_module_behind(self) -> None: def test_the_real_protocol_base_still_subscripts_afterwards(self) -> None: """The failure mode itself, rather than the table it came from. - ``pcapkit/protocols/misc/pcap/frame.py:61`` is the line that raised + ``pcapkit/protocols/misc/pcap/frame.py:69`` is the line that raised ``TypeError: type 'ProtocolBase' is not subscriptable``, so importing it after the polluting test case has run is the most direct statement of what #660 was. diff --git a/tests/vendor/test_crawler_reachability_unit.py b/tests/vendor/test_crawler_reachability_unit.py index 42d37cb4e0..29c2822c09 100644 --- a/tests/vendor/test_crawler_reachability_unit.py +++ b/tests/vendor/test_crawler_reachability_unit.py @@ -7,9 +7,9 @@ .. code-block:: python - # pcapkit/vendor/__main__.py:230, the `--target ` path + # pcapkit/vendor/__main__.py:228, the `--target ` path target_list.extend(getattr(module, name) for name in module.__all__) - # pcapkit/vendor/__main__.py:238, the default path, i.e. a bare `pcapkit-vendor` + # pcapkit/vendor/__main__.py:236, the default path, i.e. a bare `pcapkit-vendor` target_list.extend(getattr(vendor_module, name) for name in vendor_module.__all__) :attr:`pcapkit.vendor.__all__` listed ``'MH_HandoverACKStatus'`` *twice* and had