diff --git a/tests/protocols/internet/test_ipv6_ext_unit.py b/tests/protocols/internet/test_ipv6_ext_unit.py index a9524465c4..7527386915 100644 --- a/tests/protocols/internet/test_ipv6_ext_unit.py +++ b/tests/protocols/internet/test_ipv6_ext_unit.py @@ -121,9 +121,9 @@ def test_overrun_warns_and_stops_instead_of_clipping(self) -> None: def test_index_raises_because_no_class_level_identity_exists(self) -> None: """The fallback has no class-level identity, so it keeps raising rather - than being handed a placeholder index. This is also the other half of - the #917 contract in :class:`IPv6ExtSharedBaseContractTests`, which - relies on this test rather than repeating it. + than being handed a placeholder index. + :class:`IPv6ExtSharedBaseContractTests` relies on this test for that + half of the #917 contract. """ from pcapkit.protocols.internet.ipv6_ext import IPv6_Ext from pcapkit.utilities.exceptions import UnsupportedCall diff --git a/tests/protocols/misc/test_pcapng_unit.py b/tests/protocols/misc/test_pcapng_unit.py index 1930b8b584..9ca7f218a9 100644 --- a/tests/protocols/misc/test_pcapng_unit.py +++ b/tests/protocols/misc/test_pcapng_unit.py @@ -3910,8 +3910,7 @@ class PCAPNGTruncatedFileTests(unittest.TestCase): #: The result of :meth:`_sweep`, computed by the first test that asks for it #: and shared by the other three: one extraction per octet of the sample is - #: the cost of this class, and every test reads the same result (GitHub - #: issue #1062). + #: this class's whole cost (GitHub issue #1062). _swept = None # type: tuple[dict[int, int], dict[int, BaseException]] | None @classmethod 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 04dd3a4637..62fa939e91 100644 --- a/tests/protocols/schema/test_schema_metaclass_abc_cache_unit.py +++ b/tests/protocols/schema/test_schema_metaclass_abc_cache_unit.py @@ -52,10 +52,12 @@ class was reading and writing the same ``isinstance`` cache that def setUp(self) -> None: # Fresh :mod:`pcapkit` classes *and* a freshly reset - # :mod:`collections.abc` cache -- :func:`purge_modules` does both, and - # both matter: a stale positive cache entry left over from an earlier - # test in the same process would make the very first assertion below - # true for the wrong reason. + # :mod:`collections.abc` cache, for every test. Both matter: a stale + # positive cache entry left over from an earlier test in the same + # process would make the very first assertion below true for the wrong + # reason. :func:`reimport_once_per_class` resets the cache each time; + # the classes are fresh each time only because ``tearDown`` purges them + # before :func:`reimport_once_per_class` can keep them for the next test. reimport_once_per_class(self) def tearDown(self) -> None: diff --git a/tests/protocols/test_dispatch_reachability_unit.py b/tests/protocols/test_dispatch_reachability_unit.py index a52bee2114..dd4cb94a86 100644 --- a/tests/protocols/test_dispatch_reachability_unit.py +++ b/tests/protocols/test_dispatch_reachability_unit.py @@ -191,11 +191,11 @@ def __index__(cls) -> 'Any': self.assertTrue(any(name.endswith('Unreachable') for name in names), f'audit missed the injected gap; reported {names}') finally: - # ``__subclasses__`` holds a weak reference, but the class is only - # collected once nothing in this frame names it -- and, a class - # being a reference cycle of its own, once the cycle collector has - # run. Until then the next audit in the same import still sees it - # (GitHub issue #1065: no longer one import per test). + # ``__subclasses__`` holds a weak reference, but a class is a + # reference cycle of its own, so it is only collected once nothing + # in this frame names it *and* the cycle collector has run. Until + # then the next audit on the class's shared import still sees it + # (GitHub issue #1065). del Unreachable gc.collect() diff --git a/tests/protocols/test_dispatch_registry_unit.py b/tests/protocols/test_dispatch_registry_unit.py index 9c1d8e64cb..c60167b5f5 100644 --- a/tests/protocols/test_dispatch_registry_unit.py +++ b/tests/protocols/test_dispatch_registry_unit.py @@ -94,9 +94,9 @@ class DispatchRegistryTests(unittest.TestCase): """One dispatch probe per entry across all seven ``__proto__`` registries.""" #: The generator module, loaded once for the whole class. Loading it - #: imports :mod:`pcapkit`, so it must happen after :meth:`setUp` has purged - #: the previous test's copy -- hence a class attribute filled in - #: :meth:`setUpClass` rather than a module-level import. + #: imports :mod:`pcapkit`, so it must happen after the purge in + #: :meth:`setUpClass` -- hence a class attribute filled in there rather + #: than a module-level import. dispatch = None # type: Any @classmethod diff --git a/tests/protocols/test_option_roundtrip_unit.py b/tests/protocols/test_option_roundtrip_unit.py index 14b2d4ee7d..ad9f6dcc0c 100644 --- a/tests/protocols/test_option_roundtrip_unit.py +++ b/tests/protocols/test_option_roundtrip_unit.py @@ -583,9 +583,9 @@ class OptionRoundTripTests(unittest.TestCase): """One construct -> parse -> construct cycle per registered code.""" #: The generator module, loaded once for the whole class. Loading it imports - #: :mod:`pcapkit`, so it must happen after :meth:`setUp` has purged the - #: previous test's copy -- hence a class attribute filled in - #: :meth:`setUpClass` rather than a module-level import. + #: :mod:`pcapkit`, so it must happen after the purge in :meth:`setUpClass` + #: -- hence a class attribute filled in there rather than a module-level + #: import. options = None # type: Any @classmethod