@@ -249,14 +249,14 @@ def test_fastmcp_logging_middleware_is_mounted_when_enabled() -> None:
249249 ids = ["turn_off_false_still_mounts" , "turn_off_true_does_not_mount" ],
250250)
251251def test_fastmcp_logging_turn_off_middleware_still_works (turn_off : bool , expected_count : int ) -> None :
252- """The superseded flag keeps the behaviour its setter asked for, and says it is superseded."""
253- config = _make_test_config (logging_turn_off_middleware = turn_off )
252+ """The superseded flag keeps the behaviour it was set for, and says that it is superseded."""
254253 with warnings .catch_warnings (record = True ) as caught :
255254 warnings .simplefilter ("always" )
256- mounted = _mounted_logging_middleware ( config )
255+ config = _make_test_config ( logging_turn_off_middleware = turn_off )
257256
258257 assert [str (one .message ) for one in caught if "logging_turn_off_middleware" in str (one .message )]
259- assert len (mounted ) == expected_count
258+ assert config .fastmcp_logging_middleware_enabled is (not turn_off )
259+ assert len (_mounted_logging_middleware (config )) == expected_count
260260
261261
262262def test_fastmcp_logging_turn_off_middleware_warning_names_the_caller () -> None :
@@ -265,14 +265,33 @@ def test_fastmcp_logging_turn_off_middleware_warning_names_the_caller() -> None:
265265 Same reason as the config-validation warnings in test_config_cascade.py: every frame between
266266 the warn call and the user is lite-bootstrap's, and the distance is not a constant.
267267 """
268- config = _make_test_config (logging_turn_off_middleware = True )
269268 with warnings .catch_warnings (record = True ) as caught :
270269 warnings .simplefilter ("always" )
271- _mounted_logging_middleware ( config )
270+ _make_test_config ( logging_turn_off_middleware = True )
272271
273272 assert warning_source_files (caught , UserWarning ) == [__file__ ]
274273
275274
275+ @pytest .mark .parametrize ("overrides" , [{}, {"fastmcp_logging_middleware_enabled" : True }], ids = ["default" , "enabled" ])
276+ def test_fastmcp_logging_warns_nothing_without_the_superseded_flag (overrides : dict [str , bool ]) -> None :
277+ with warnings .catch_warnings (record = True ) as caught :
278+ warnings .simplefilter ("always" )
279+ _make_test_config (** overrides )
280+
281+ assert [str (one .message ) for one in caught ] == []
282+
283+
284+ def test_fastmcp_logging_explicit_flag_wins_over_the_superseded_one () -> None :
285+ """Setting both keeps the current field and says the superseded one is ignored."""
286+ with warnings .catch_warnings (record = True ) as caught :
287+ warnings .simplefilter ("always" )
288+ config = _make_test_config (fastmcp_logging_middleware_enabled = True , logging_turn_off_middleware = True )
289+
290+ assert [one for one in caught if "is ignored because" in str (one .message )]
291+ assert config .fastmcp_logging_middleware_enabled is True
292+ assert len (_mounted_logging_middleware (config )) == 1
293+
294+
276295@pytest .mark .parametrize (
277296 ("package_name" , "extra_config" ),
278297 [
0 commit comments