documentation_tests.txt - sort filenames alphabetically (#24647)

* Sort filenames alphabetically

* Add check for order
This commit is contained in:
amyeroberts
2023-07-04 17:06:05 +01:00
committed by GitHub
parent a3b402ff9a
commit f3e96235a3
2 changed files with 285 additions and 281 deletions

View File

@@ -24,12 +24,16 @@ REPO_PATH = "."
if __name__ == "__main__":
doctest_file_path = os.path.join(REPO_PATH, "utils/documentation_tests.txt")
non_existent_paths = []
all_paths = []
with open(doctest_file_path) as fp:
for line in fp:
line = line.strip()
path = os.path.join(REPO_PATH, line)
if not (os.path.isfile(path) or os.path.isdir(path)):
non_existent_paths.append(line)
all_paths.append(path)
if len(non_existent_paths) > 0:
non_existent_paths = "\n".join(non_existent_paths)
raise ValueError(f"`utils/documentation_tests.txt` contains non-existent paths:\n{non_existent_paths}")
if all_paths != sorted(all_paths):
raise ValueError("Files in `utils/documentation_tests.txt` are not in alphabetical order.")