diff --git a/deeptutor/tools/tex_downloader.py b/deeptutor/tools/tex_downloader.py index 1944fc00e..84a979cd3 100644 --- a/deeptutor/tools/tex_downloader.py +++ b/deeptutor/tools/tex_downloader.py @@ -189,7 +189,8 @@ class TexDownloader: 3. Tex file containing \\documentclass 4. Largest tex file """ - tex_files = list(directory.rglob("*.tex")) + # Windows globbing also returns uppercase extensions. + tex_files = [path for path in directory.rglob("*.tex") if path.name.endswith(".tex")] if not tex_files: return None diff --git a/tests/tools/test_tex_tools.py b/tests/tools/test_tex_tools.py index e9f67b886..c423a3049 100644 --- a/tests/tools/test_tex_tools.py +++ b/tests/tools/test_tex_tools.py @@ -309,12 +309,26 @@ class TestFindMainTex: found = downloader._find_main_tex(tmp_path) assert found is not None and found.name == "Main.tex" + @pytest.mark.parametrize("case_insensitive_glob", [False, True]) def test_uppercase_extension_file_is_invisible( - self, downloader: TexDownloader, tmp_path: Path + self, + downloader: TexDownloader, + tmp_path: Path, + monkeypatch: pytest.MonkeyPatch, + case_insensitive_glob: bool, ) -> None: - # Known limitation: discovery globs "*.tex" case-sensitively, so a file - # named MAIN.TEX is never even considered a candidate. - (tmp_path / "MAIN.TEX").write_text("upper", encoding="utf-8") + uppercase = tmp_path / "MAIN.TEX" + uppercase.write_text("upper", encoding="utf-8") + if case_insensitive_glob: + rglob = Path.rglob + + def glob_with_uppercase(path: Path, pattern: str): + if path == tmp_path and pattern == "*.tex": + return iter([uppercase]) + return rglob(path, pattern) + + monkeypatch.setattr(Path, "rglob", glob_with_uppercase) + assert downloader._find_main_tex(tmp_path) is None