MCPcopy
hub / github.com/microsoft/agent-lightning / test_setup_files_mapping_spawn

Function test_setup_files_mapping_spawn

tests/test_logging.py:383–422  ·  view source on GitHub ↗

Verifies that passing files as a mapping attaches FileHandlers to each logger and that calling setup twice does not create duplicate handlers.

(tmp_path: Path)

Source from the content-addressed store, hash-verified

381
382
383def test_setup_files_mapping_spawn(tmp_path: Path) -> None:
384 """
385 Verifies that passing files as a mapping attaches FileHandlers to each
386 logger and that calling setup twice does not create duplicate handlers.
387 """
388 ctx = mp.get_context("spawn")
389 q: Queue[Dict[str, Any]] = ctx.Queue()
390 p = ctx.Process(target=_logging_worker_files_mapping, args=(q, str(tmp_path)))
391 p.start()
392 result = q.get(timeout=10)
393 p.join(timeout=10)
394 assert p.exitcode == 0
395
396 # Base logger level is DEBUG
397 assert result["base_level"] == logging.DEBUG
398
399 # External's effective level is WARNING (inherited from root)
400 assert result["ext_level"] == logging.WARNING
401
402 # First setup: one FileHandler per logger
403 assert result["base_first_count"] == 1
404 assert result["ext_first_count"] == 1
405
406 # Second setup: still one FileHandler per logger (idempotence)
407 assert result["base_second_count"] == 1
408 assert result["ext_second_count"] == 1
409
410 # File paths are stable across calls
411 assert result["base_file_first"] == result["base_file_second"]
412 assert result["ext_file_first"] == result["ext_file_second"]
413
414 # Paths should live under tmp_path
415 assert str(tmp_path) in result["base_file_first"]
416 assert str(tmp_path) in result["ext_file_first"]
417
418 # Handler levels:
419 # - base handler uses the base logger level (DEBUG)
420 # - external handler uses external's effective level at creation (WARNING)
421 assert result["base_handler_level"] == logging.DEBUG
422 assert result["ext_handler_level"] == logging.WARNING

Callers

nothing calls this directly

Calls 2

startMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected