From a81fd35524434521994204ca16a42562c5c04853 Mon Sep 17 00:00:00 2001 From: Sylvain Gugger <35901082+sgugger@users.noreply.github.com> Date: Thu, 27 Jan 2022 14:17:48 -0500 Subject: [PATCH] Fix tests_fetcher (#15376) --- utils/tests_fetcher.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/utils/tests_fetcher.py b/utils/tests_fetcher.py index 1036981a62..e842055d93 100644 --- a/utils/tests_fetcher.py +++ b/utils/tests_fetcher.py @@ -197,7 +197,10 @@ def get_test_dependencies(test_fname): # Tests only have relative imports for other test files relative_imports = re.findall(r"from\s+\.(\S+)\s+import\s+([^\n]+)\n", content) relative_imports = [test for test, imp in relative_imports if "# tests_ignore" not in imp] - return [os.path.join("tests", f"{test}.py") for test in relative_imports] + dependencies = [os.path.join("tests", f"{test}.py") for test in relative_imports] + # Some tests use docstrings with relative imports in them and this could catch them, so we check the files + # actually exist + return [f for f in dependencies if os.path.isfile(f)] def create_reverse_dependency_map():