Skip to content

Commit 3da5904

Browse files
committed
Simplify
1 parent b3f6cd9 commit 3da5904

3 files changed

Lines changed: 12 additions & 23 deletions

File tree

sqlmesh/core/console.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -499,10 +499,6 @@ def loading_start(self, message: t.Optional[str] = None) -> uuid.UUID:
499499
def loading_stop(self, id: uuid.UUID) -> None:
500500
"""Stop loading for the given id."""
501501

502-
@abc.abstractmethod
503-
def log_unit_test_results(self, result: ModelTextTestResult) -> None:
504-
"""Print the unit test results."""
505-
506502

507503
class NoopConsole(Console):
508504
def start_plan_evaluation(self, plan: EvaluatablePlan) -> None:
@@ -782,9 +778,6 @@ def start_destroy(self) -> bool:
782778
def stop_destroy(self, success: bool = True) -> None:
783779
pass
784780

785-
def log_unit_test_results(self, result: ModelTextTestResult) -> None:
786-
pass
787-
788781

789782
def make_progress_bar(
790783
message: str,
@@ -1963,7 +1956,7 @@ def _prompt_promote(self, plan_builder: PlanBuilder) -> None:
19631956
def log_test_results(self, result: ModelTextTestResult, target_dialect: str) -> None:
19641957
divider_length = 70
19651958

1966-
self.log_unit_test_results(result)
1959+
self._log_unit_test_results(result)
19671960
self._print("\n")
19681961

19691962
if result.wasSuccessful():
@@ -1987,7 +1980,7 @@ def log_test_results(self, result: ModelTextTestResult, target_dialect: str) ->
19871980

19881981
def _captured_unit_test_results(self, result: ModelTextTestResult) -> str:
19891982
with self.console.capture() as capture:
1990-
self.log_unit_test_results(result)
1983+
self._log_unit_test_results(result)
19911984
return strip_ansi_codes(capture.get())
19921985

19931986
def show_sql(self, sql: str) -> None:
@@ -2506,7 +2499,14 @@ def show_linter_violations(
25062499
else:
25072500
self.log_warning(msg)
25082501

2509-
def log_unit_test_results(self, result: ModelTextTestResult) -> None:
2502+
def _log_unit_test_results(self, result: ModelTextTestResult) -> None:
2503+
"""
2504+
This is a helper method that encapsulates the logic for logging the relevant unittest for the result.
2505+
The top level method (`log_test_results`) reuses `_log_unit_test_results` differently based on the console.
2506+
2507+
Args:
2508+
result: The unittest test result that contains metrics like num success, fails, ect.
2509+
"""
25102510
tests_run = result.testsRun
25112511
errors = result.errors
25122512
failures = result.failures
@@ -3208,7 +3208,7 @@ def log_test_results(self, result: ModelTextTestResult, target_dialect: str) ->
32083208
)
32093209
else:
32103210
self._print("```")
3211-
self.log_unit_test_results(result)
3211+
self._log_unit_test_results(result)
32123212
self._print("```\n\n")
32133213

32143214
self._print(

sqlmesh/core/test/result.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,6 @@ def addSuccess(self, test: unittest.TestCase) -> None:
102102

103103
self.successes.append(test)
104104

105-
def log_test_report(self) -> None:
106-
"""
107-
Log the test report following unittest's conventions.
108-
109-
Args:
110-
test_duration: The duration of the tests.
111-
"""
112-
from sqlmesh.core.console import get_console
113-
114-
get_console().log_unit_test_results(self)
115-
116105
def merge(self, other: ModelTextTestResult) -> None:
117106
if other.successes:
118107
self.addSuccess(other.successes[0])

tests/core/test_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2631,7 +2631,7 @@ def test_model_test_text_result_reporting_no_traceback(
26312631
result.addFailure(test, (e.__class__, e, e.__traceback__))
26322632

26332633
with capture_output() as captured_output:
2634-
result.log_test_report()
2634+
get_console().log_test_results(result, "duckdb")
26352635

26362636
output = captured_output.stdout
26372637

0 commit comments

Comments
 (0)