Skip to content

Build AI methods with your coding agent, then run them anywhere: as an MCP for chatbots, as a webapp for people, or via API for your software.

fix(test): restore PrettyPrinter.mode in agent CLI factory init-overrides fixture

Louis Choquel62f0e944abba
diff --git a/tests/unit/pipelex/cli/test_agent_cli_factory_init_overrides.py b/tests/unit/pipelex/cli/test_agent_cli_factory_init_overrides.py
index 85992d3a6..0d87021e7 100644
--- a/tests/unit/pipelex/cli/test_agent_cli_factory_init_overrides.py
+++ b/tests/unit/pipelex/cli/test_agent_cli_factory_init_overrides.py
@@ -32,20 +32,28 @@ from pipelex.cli.agent_cli.commands.agent_cli_factory import (
)
from pipelex.system.console_target import ConsoleTarget
from pipelex.tools.log.log_levels import LogLevel
+from pipelex.tools.misc.pretty import PrettyPrinter
class TestAgentCliFactoryInitOverrides:
"""Pins the contract that init-time logs are suppressed via global cutoff + overrides."""
@pytest.fixture(autouse=True)
- def _restore_global_logging_disable(self):
- """``make_pipelex_for_agent_cli`` mutates process-global state via
- ``logging.disable``. Snapshot the manager's disable level and restore it after
- each test so the agent CLI cutoff does not leak into other tests in the suite.
+ def _restore_globals(self):
+ """``make_pipelex_for_agent_cli`` mutates two pieces of process-global state:
+ ``logging.disable`` (via ``silence_logging_for_agent_cli``) and
+ ``PrettyPrinter.mode`` (set to ``SILENT`` by ``apply_agent_cli_output_discipline``
+ at the end of the factory). Snapshot both and restore them after each test so
+ the agent CLI's discipline does not leak into other test classes in the same
+ xdist worker — under pytest-xdist the failure mode is downstream
+ ``pretty_print``-based tests (e.g. ``test_json_content_rendering``) producing
+ empty output and asserting ``'x' in ''``.
"""
original_disable = logging.root.manager.disable
+ original_pretty_mode = PrettyPrinter.mode
yield
logging.disable(original_disable)
+ PrettyPrinter.mode = original_pretty_mode
def test_static_leaf_pins_off_for_pipelex_package(self) -> None:
"""The doctor path and the full-init path BOTH use ``AGENT_CLI_STDERR_LOG_FIELDS``,