Skip to content

Commit b63987e

Browse files
committed
chore: debug flaky test
1 parent f73d245 commit b63987e

File tree

2 files changed

+13
-26
lines changed

2 files changed

+13
-26
lines changed

tests/cli/test_cli.py

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import json
2-
import logging
32
import os
43
import pytest
54
import string
65
import time_machine
7-
from contextlib import contextmanager
86
from os import getcwd, path, remove
97
from pathlib import Path
108
from shutil import rmtree
@@ -35,15 +33,6 @@ def runner() -> CliRunner:
3533
return CliRunner(env={"COLUMNS": "80"})
3634

3735

38-
@contextmanager
39-
def disable_logging():
40-
logging.disable(logging.CRITICAL)
41-
try:
42-
yield
43-
finally:
44-
logging.disable(logging.NOTSET)
45-
46-
4736
def create_example_project(temp_dir, template=ProjectTemplate.DEFAULT) -> None:
4837
"""
4938
Sets up CLI tests requiring a real SQLMesh project by:
@@ -795,8 +784,7 @@ def test_run_cron_not_elapsed(runner, tmp_path, caplog):
795784
init_prod_and_backfill(runner, tmp_path)
796785

797786
# No error if `prod` environment exists and cron has not elapsed
798-
with disable_logging():
799-
result = runner.invoke(cli, ["--log-file-dir", tmp_path, "--paths", tmp_path, "run"])
787+
result = runner.invoke(cli, ["--log-file-dir", tmp_path, "--paths", tmp_path, "run"])
800788
assert result.exit_code == 0
801789

802790
assert (
@@ -843,18 +831,17 @@ def test_table_name(runner, tmp_path):
843831
# Create and backfill `prod` environment
844832
create_example_project(tmp_path)
845833
init_prod_and_backfill(runner, tmp_path)
846-
with disable_logging():
847-
result = runner.invoke(
848-
cli,
849-
[
850-
"--log-file-dir",
851-
tmp_path,
852-
"--paths",
853-
tmp_path,
854-
"table_name",
855-
"sqlmesh_example.full_model",
856-
],
857-
)
834+
result = runner.invoke(
835+
cli,
836+
[
837+
"--log-file-dir",
838+
tmp_path,
839+
"--paths",
840+
tmp_path,
841+
"table_name",
842+
"sqlmesh_example.full_model",
843+
],
844+
)
858845
assert result.exit_code == 0
859846
assert result.output.startswith("db.sqlmesh__sqlmesh_example.sqlmesh_example__full_model__")
860847

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def rescope_duckdb_classvar(request):
247247
yield
248248

249249

250-
@pytest.fixture(scope="module", autouse=True)
250+
@pytest.fixture(scope="function", autouse=True)
251251
def rescope_log_handlers():
252252
logging.getLogger().handlers.clear()
253253
yield

0 commit comments

Comments
 (0)