Skip to content

Commit 93c7a10

Browse files
authored
Chore: make console width deterministic in tests (#5477)
1 parent 9ed6744 commit 93c7a10

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

tests/cli/test_cli.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def mock_runtime_env(monkeypatch):
3232

3333
@pytest.fixture(scope="session")
3434
def runner() -> CliRunner:
35-
return CliRunner()
35+
return CliRunner(env={"COLUMNS": "80"})
3636

3737

3838
@contextmanager
@@ -1887,7 +1887,9 @@ def test_init_interactive_cli_mode_simple(runner: CliRunner, tmp_path: Path):
18871887
assert "no_diff: true" in config_path.read_text()
18881888

18891889

1890-
def test_init_interactive_engine_install_msg(runner: CliRunner, tmp_path: Path):
1890+
def test_init_interactive_engine_install_msg(runner: CliRunner, tmp_path: Path, monkeypatch):
1891+
monkeypatch.setattr("sqlmesh.utils.rich.console.width", 80)
1892+
18911893
# Engine install text should not appear for built-in engines like DuckDB
18921894
# Input: 1 (DEFAULT template), 1 (duckdb engine), 1 (DEFAULT CLI mode)
18931895
result = runner.invoke(

tests/utils/test_helpers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def test_wrapper(*args, **kwargs):
8383
orig_console = get_console()
8484
try:
8585
new_console = TerminalConsole()
86+
new_console.console.width = 80
8687
new_console.console.no_color = True
8788
set_console(new_console)
8889
func(*args, **kwargs)

0 commit comments

Comments
 (0)