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

Function test_setup_files_string_spawn

tests/test_logging.py:355–380  ·  view source on GitHub ↗

Verifies that passing files as a string attaches a single FileHandler with the expected level and default formatter in a spawned process.

(tmp_path: Path)

Source from the content-addressed store, hash-verified

353
354
355def test_setup_files_string_spawn(tmp_path: Path) -> None:
356 """
357 Verifies that passing files as a string attaches a single FileHandler with
358 the expected level and default formatter in a spawned process.
359 """
360 ctx = mp.get_context("spawn")
361 q: Queue[Dict[str, Any]] = ctx.Queue()
362 p = ctx.Process(target=_logging_worker_files_string, args=(q, str(tmp_path)))
363 p.start()
364 result = q.get(timeout=10)
365 p.join(timeout=10)
366 assert p.exitcode == 0
367
368 assert result["logger_level"] == logging.INFO
369 # We expect at least one handler and exactly one FileHandler
370 assert result["num_handlers"] >= 1
371 assert result["num_file_handlers"] == 1
372
373 # Filename should be inside the tmp_path tree
374 assert str(tmp_path) in result["file_base"]
375 # FileHandler uses the base logger level
376 assert result["file_level"] == logging.INFO
377
378 # Default formatter applied by _ensure_file_handler
379 assert result["fmt"] == DEFAULT_FORMAT
380 assert result["datefmt"] == DATE_FORMAT
381
382
383def test_setup_files_mapping_spawn(tmp_path: Path) -> None:

Callers

nothing calls this directly

Calls 2

startMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected