Found a regression: potodo now parses ignored files even if it don't use them.

This commit is contained in:
Julien Palard 2023-03-13 13:07:33 +01:00
parent ece04451e2
commit 3a928ef053
Signed by: mdk
GPG Key ID: 0EFC1AC1006886F8
3 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1 @@
b23b16c23935672275fb31f82345acc29eccb056

20
tests/fixtures/git_repository/file1.po vendored Normal file
View File

@ -0,0 +1,20 @@
#: /un/chemin/idiot.rst:69
msgid "This is a dummy sentence."
msgstr "Ceci est une phrase bateau."
#, fuzzy
#: /un/chemin/idiot.rst:420
msgid "Incredibly useful as a tool, this potodo"
msgstr "Incroyablement inutile comme outil, ce potodo"
#: /un/chemin/idiot.rst:666
msgid "We should translate this eventually"
msgstr ""
#~ msgid "Hello darkness my old friend"
#~ msgstr "Vous qui lisez cette ligne, vous êtes très beau."
#, fuzzy
#~ msgid "I am only there to make sure"
#~ msgstr "I don't get counted as a fuzzy entry"

View File

@ -1,8 +1,30 @@
from pathlib import Path
import pytest
from potodo.potodo import main
REPO_DIR = Path(__file__).resolve().parent / "fixtures" / "repository"
GIT_REPO_DIR = Path(__file__).resolve().parent / "fixtures" / "git_repository"
@pytest.mark.xfail(strict=True)
def test_git(capsys, monkeypatch):
"""Ensure than excluded files are **not** parsed.
Parsing excluded files can lead to surprises, here, parsing a
`.po` file in `.git` may not work, it may just be a branch or
whatever and contain a sha1 instead.
I name it dotgit instead of .git, to not scare git.
"""
monkeypatch.setattr(
"sys.argv", ["potodo", "-p", str(GIT_REPO_DIR), "--exclude", "dotgit/"]
)
main()
out, err = capsys.readouterr()
assert not err
assert "file1" in out
def test_no_exclude(capsys, monkeypatch):