From db0b592af7b423ed7d00c89861c995836b8854ea Mon Sep 17 00:00:00 2001 From: Jarry Shaw Date: Sat, 10 Oct 2026 08:45:33 -0400 Subject: [PATCH] fix(utilities): export hold_warnings in pcapkit.utilities.warnings.__all__ (#1602) `hold_warnings` is public -- documented by `autoclass` and imported by `pcapkit.protocols.protocol` -- but was missing from `__all__`, so `from pcapkit.utilities.warnings import *` did not bring it in. List it beside `warn`, as the stdlib lists `catch_warnings`. The name stays lowercase per the ruling on #1599. A new test pins the entry and the star import. --- pcapkit/utilities/warnings.py | 2 +- tests/protocols/test_trial_parse_warnings_1580_unit.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pcapkit/utilities/warnings.py b/pcapkit/utilities/warnings.py index dc282aa583..62fd211ab1 100644 --- a/pcapkit/utilities/warnings.py +++ b/pcapkit/utilities/warnings.py @@ -75,7 +75,7 @@ HeldWarning = Tuple[Union[str, Warning], Type[Warning], Optional[FrameType]] __all__ = [ - 'warn', + 'warn', 'hold_warnings', # UserWarning 'BaseWarning', diff --git a/tests/protocols/test_trial_parse_warnings_1580_unit.py b/tests/protocols/test_trial_parse_warnings_1580_unit.py index 4caf9552b4..12215c7334 100644 --- a/tests/protocols/test_trial_parse_warnings_1580_unit.py +++ b/tests/protocols/test_trial_parse_warnings_1580_unit.py @@ -468,6 +468,15 @@ def test_filters_and_registries_are_untouched(self) -> None: self.assertEqual(len(unrelated), 1) self.assertEqual(self._schema(caught), TCP_CUT_MESSAGES) + def test_hold_warnings_is_exported(self) -> None: + """``import *`` brings ``hold_warnings`` in, as it does ``warnings.catch_warnings`` (#1602).""" + import pcapkit.utilities.warnings as warnings_module + + self.assertIn('hold_warnings', warnings_module.__all__) + namespace = {} # type: dict[str, Any] + exec('from pcapkit.utilities.warnings import *', namespace) # pylint: disable=exec-used + self.assertIs(namespace['hold_warnings'], warnings_module.hold_warnings) + if __name__ == '__main__': unittest.main()