Skip to content

Commit 118e7e9

Browse files
authored
Chore: do not log test results if there are no tests (#4785)
1 parent 00d30f7 commit 118e7e9

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

sqlmesh/core/console.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,6 +1954,10 @@ def _prompt_promote(self, plan_builder: PlanBuilder) -> None:
19541954
plan_builder.apply()
19551955

19561956
def log_test_results(self, result: ModelTextTestResult, target_dialect: str) -> None:
1957+
# We don't log the test results if no tests were ran
1958+
if not result.testsRun:
1959+
return
1960+
19571961
divider_length = 70
19581962

19591963
self._log_test_details(result)
@@ -2827,6 +2831,10 @@ def radio_button_selected(change: t.Dict[str, t.Any]) -> None:
28272831
self.display(radio)
28282832

28292833
def log_test_results(self, result: ModelTextTestResult, target_dialect: str) -> None:
2834+
# We don't log the test results if no tests were ran
2835+
if not result.testsRun:
2836+
return
2837+
28302838
import ipywidgets as widgets
28312839

28322840
divider_length = 70
@@ -3206,6 +3214,10 @@ def log_success(self, message: str) -> None:
32063214
self._print(message)
32073215

32083216
def log_test_results(self, result: ModelTextTestResult, target_dialect: str) -> None:
3217+
# We don't log the test results if no tests were ran
3218+
if not result.testsRun:
3219+
return
3220+
32093221
message = f"Ran `{result.testsRun}` Tests Against `{target_dialect}`"
32103222

32113223
if result.wasSuccessful():

tests/core/test_test.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2685,6 +2685,10 @@ def test_model_test_text_result_reporting_no_traceback(
26852685
else:
26862686
result.addFailure(test, (e.__class__, e, e.__traceback__))
26872687

2688+
# Since we're simulating an error/failure, this doesn't go through the
2689+
# test runner logic, so we need to manually set how many tests were ran
2690+
result.testsRun = 1
2691+
26882692
with capture_output() as captured_output:
26892693
get_console().log_test_results(result, "duckdb")
26902694

@@ -2729,3 +2733,23 @@ def test_timestamp_normalization() -> None:
27292733
context=Context(config=Config(model_defaults=ModelDefaultsConfig(dialect="duckdb"))),
27302734
).run()
27312735
)
2736+
2737+
2738+
@use_terminal_console
2739+
def test_disable_test_logging_if_no_tests_found(mocker: MockerFixture, tmp_path: Path) -> None:
2740+
init_example_project(tmp_path, dialect="duckdb")
2741+
2742+
config = Config(
2743+
default_connection=DuckDBConnectionConfig(),
2744+
model_defaults=ModelDefaultsConfig(dialect="duckdb"),
2745+
default_test_connection=DuckDBConnectionConfig(concurrent_tasks=8),
2746+
)
2747+
2748+
rmtree(tmp_path / "tests")
2749+
2750+
with capture_output() as captured_output:
2751+
context = Context(paths=tmp_path, config=config)
2752+
context.plan(no_prompts=True, auto_apply=True)
2753+
2754+
output = captured_output.stdout
2755+
assert "test" not in output.lower()

0 commit comments

Comments
 (0)