Skip to content

Commit d28523e

Browse files
committed
PR Feedback 2
1 parent 3d4f9f0 commit d28523e

3 files changed

Lines changed: 12 additions & 14 deletions

File tree

sqlmesh/core/context.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2460,13 +2460,13 @@ def lint_models(
24602460
def load_model_tests(
24612461
self, tests: t.Optional[t.List[str]] = None, patterns: list[str] | None = None
24622462
) -> t.List[ModelTestMetadata]:
2463-
# If a set of tests is provided, use a single loader to load them
2464-
# Otherwise, gather all tests from all loaders/repos
2463+
# If a set of specific test path(s) are provided, we can use a single loader
2464+
# since it's not required to walk every tests/ folder in each repo
24652465
loaders = [self._loaders[0]] if tests else self._loaders
24662466

24672467
model_tests = []
24682468
for loader in loaders:
2469-
model_tests.extend(loader._load_model_tests(tests=tests, patterns=patterns))
2469+
model_tests.extend(loader.load_model_tests(tests=tests, patterns=patterns))
24702470

24712471
return model_tests
24722472

sqlmesh/core/loader.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def _load_linting_rules(self) -> RuleSet:
293293
"""Loads user linting rules"""
294294
return RuleSet()
295295

296-
def _load_model_tests(
296+
def load_model_tests(
297297
self, tests: t.Optional[t.List[str]] = None, patterns: list[str] | None = None
298298
) -> t.List[ModelTestMetadata]:
299299
"""Loads YAML-based model tests"""
@@ -699,21 +699,21 @@ def _load_model_test_file(self, path: Path) -> dict[str, ModelTestMetadata]:
699699

700700
return model_test_metadata
701701

702-
def _load_model_tests(
702+
def load_model_tests(
703703
self, tests: t.Optional[t.List[str]] = None, patterns: list[str] | None = None
704704
) -> t.List[ModelTestMetadata]:
705705
"""Loads YAML-based model tests"""
706-
test_meta: t.List[ModelTestMetadata] = []
706+
test_meta_list: t.List[ModelTestMetadata] = []
707707

708708
if tests:
709709
for test in tests:
710710
filename, test_name = test.split("::", maxsplit=1) if "::" in test else (test, "")
711711

712-
test_file = self._load_model_test_file(Path(filename))
712+
test_meta = self._load_model_test_file(Path(filename))
713713
if test_name:
714-
test_meta.append(test_file[test_name])
714+
test_meta_list.append(test_meta[test_name])
715715
else:
716-
test_meta.extend(test_file.values())
716+
test_meta_list.extend(test_meta.values())
717717
else:
718718
search_path = Path(self.config_path) / c.TESTS
719719

@@ -727,12 +727,12 @@ def _load_model_tests(
727727
):
728728
continue
729729

730-
test_meta.extend(self._load_model_test_file(yaml_file).values())
730+
test_meta_list.extend(self._load_model_test_file(yaml_file).values())
731731

732732
if patterns:
733-
test_meta = filter_tests_by_patterns(test_meta, patterns)
733+
test_meta_list = filter_tests_by_patterns(test_meta_list, patterns)
734734

735-
return test_meta
735+
return test_meta_list
736736

737737
class _Cache(CacheBase):
738738
def __init__(self, loader: SqlMeshLoader, config_path: Path):

tests/core/test_test.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2319,7 +2319,6 @@ def test_number_of_tests_found(tmp_path: Path) -> None:
23192319
"""
23202320
test_example_full_model1:
23212321
model: sqlmesh_example.full_model
2322-
description: This is an invalid test
23232322
inputs:
23242323
sqlmesh_example.incremental_model:
23252324
rows:
@@ -2339,7 +2338,6 @@ def test_number_of_tests_found(tmp_path: Path) -> None:
23392338
23402339
test_example_full_model2:
23412340
model: sqlmesh_example.full_model
2342-
description: This is an invalid test
23432341
inputs:
23442342
sqlmesh_example.incremental_model:
23452343
rows:

0 commit comments

Comments
 (0)