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()