Skip to content

Commit b91eec3

Browse files
sguggernovice03
authored andcommitted
Fix expected value in tests of the test fetcher (huggingface#24077)
* Fix expected value in tests of the test fetcher * Fix trigger for repo util tests
1 parent e1b09f0 commit b91eec3

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

tests/repo_utils/test_tests_fetcher.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -526,10 +526,17 @@ def test_init_test_examples_dependencies(self):
526526
create_tmp_repo(tmp_folder)
527527

528528
expected_example_deps = {
529-
"examples/flax/test_flax_examples.py": ["examples/flax/text-classification/run_glue.py"],
530-
"examples/pytorch/test_pytorch_examples.py": ["examples/pytorch/text-classification/run_glue.py"],
529+
"examples/flax/test_flax_examples.py": [
530+
"examples/flax/text-classification/run_glue.py",
531+
"examples/flax/test_flax_examples.py",
532+
],
533+
"examples/pytorch/test_pytorch_examples.py": [
534+
"examples/pytorch/text-classification/run_glue.py",
535+
"examples/pytorch/test_pytorch_examples.py",
536+
],
531537
"examples/tensorflow/test_tensorflow_examples.py": [
532-
"examples/tensorflow/text-classification/run_glue.py"
538+
"examples/tensorflow/text-classification/run_glue.py",
539+
"examples/tensorflow/test_tensorflow_examples.py",
533540
],
534541
}
535542

utils/tests_fetcher.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,9 @@ def extract_imports(module_fname, cache=None):
353353
content = f.read()
354354

355355
# Filter out all docstrings to not get imports in code examples.
356-
splits = content.split('"""')
356+
# fmt: off
357+
splits = content.split('\"\"\"')
358+
# fmt: on
357359
content = "".join(splits[::2])
358360

359361
module_parts = str(module_fname).split(os.path.sep)
@@ -694,12 +696,14 @@ def infer_tests_to_run(output_file, diff_with_last_commit=False, filter_models=T
694696
if f in test_map:
695697
test_files_to_run.extend(test_map[f])
696698
test_files_to_run = sorted(set(test_files_to_run))
699+
# Remove repo utils tests
700+
test_files_to_run = [f for f in test_files_to_run if not f.split(os.path.sep)[1] == "repo_utils"]
697701
# Remove SageMaker tests
698702
test_files_to_run = [f for f in test_files_to_run if not f.split(os.path.sep)[1] == "sagemaker"]
699703
# Make sure we did not end up with a test file that was removed
700704
test_files_to_run = [f for f in test_files_to_run if (PATH_TO_REPO / f).exists()]
701705

702-
repo_utils_launch = any(f.split(os.path.sep)[1] == "repo_utils" for f in modified_files)
706+
repo_utils_launch = any(f.split(os.path.sep)[0] == "utils" for f in modified_files)
703707

704708
if repo_utils_launch:
705709
repo_util_file = Path(output_file).parent / "test_repo_utils.txt"

0 commit comments

Comments
 (0)