From 1fb73e4d14849c601c4c65a58896c7d8c544bf6f Mon Sep 17 00:00:00 2001 From: George Sittas Date: Fri, 3 Oct 2025 11:19:20 +0300 Subject: [PATCH] Chore: make console width deterministic in tests --- tests/cli/test_cli.py | 6 ++++-- tests/utils/test_helpers.py | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/cli/test_cli.py b/tests/cli/test_cli.py index 1be44e18f9..d2df451fef 100644 --- a/tests/cli/test_cli.py +++ b/tests/cli/test_cli.py @@ -32,7 +32,7 @@ def mock_runtime_env(monkeypatch): @pytest.fixture(scope="session") def runner() -> CliRunner: - return CliRunner() + return CliRunner(env={"COLUMNS": "80"}) @contextmanager @@ -1887,7 +1887,9 @@ def test_init_interactive_cli_mode_simple(runner: CliRunner, tmp_path: Path): assert "no_diff: true" in config_path.read_text() -def test_init_interactive_engine_install_msg(runner: CliRunner, tmp_path: Path): +def test_init_interactive_engine_install_msg(runner: CliRunner, tmp_path: Path, monkeypatch): + monkeypatch.setattr("sqlmesh.utils.rich.console.width", 80) + # Engine install text should not appear for built-in engines like DuckDB # Input: 1 (DEFAULT template), 1 (duckdb engine), 1 (DEFAULT CLI mode) result = runner.invoke( diff --git a/tests/utils/test_helpers.py b/tests/utils/test_helpers.py index ae0742f1db..20a544512e 100644 --- a/tests/utils/test_helpers.py +++ b/tests/utils/test_helpers.py @@ -83,6 +83,7 @@ def test_wrapper(*args, **kwargs): orig_console = get_console() try: new_console = TerminalConsole() + new_console.console.width = 80 new_console.console.no_color = True set_console(new_console) func(*args, **kwargs)