Fix for #832 by Edwin18 · Pull Request #1052 · python-babel/babel

Very simple minor fix 711676b

To make test work properly just add another value to our ignore list and it imidiately fails.
Multiple args works fine:
--ignore-dirs '_*' --ignore-dirs '*ignored*'
but not multiple values:
--ignore-dirs '*ignored* _*'

Before, function argument fix:

=============test session starts=============
platform linux -- Python 3.10.11, pytest-7.4.3, pluggy-1.3.0 -- /home/mrgreen/code/babel/venv/bin/python3
cachedir: .pytest_cache
rootdir: /home/mrgreen/code/babel
configfile: setup.cfg
plugins: cov-4.1.0
collected 60 items / 58 deselected / 2 selected                                                                                                                                                                                                                                                         

tests/messages/test_frontend.py::test_extract_ignore_dirs[False] 
ignore_dirs = ['*ignored*', '.*'] 
FAILED
tests/messages/test_frontend.py::test_extract_ignore_dirs[True] 
ignore_dirs = ['*ignored*', '.*', '_*'] 
FAILED

=============FAILURES =============
______________________ test_extract_ignore_dirs[False] ______________________

monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7febbf363280>, capsys = <_pytest.capture.CaptureFixture object at 0x7febbf363520>, tmp_path = PosixPath('/tmp/pytest-of-mrgreen/pytest-33/test_extract_ignore_dirs_False0'), with_underscore_ignore = False

    @pytest.mark.parametrize("with_underscore_ignore", (False, True))
    def test_extract_ignore_dirs(monkeypatch, capsys, tmp_path, with_underscore_ignore):
        pot_file = tmp_path / 'temp.pot'
        monkeypatch.chdir(project_dir)
        cmd = f"extract . -o '{pot_file}' --ignore-dirs '*ignored* .*' "
        if with_underscore_ignore:
            # This also tests that multiple arguments are supported.
            cmd += "--ignore-dirs '_*'"
        cmdinst = configure_cli_command(cmd)
        assert isinstance(cmdinst, ExtractMessages)
        assert cmdinst.directory_filter
        cmdinst.run()
        pot_content = pot_file.read_text()
    
        # The `ignored` directory is now actually ignored:
>       assert 'this_wont_normally_be_here' not in pot_content
E       assert 'this_wont_normally_be_here' not in '# Translati...tr[1] ""\n\n'
E         'this_wont_normally_be_here' is contained here:
E           # Translations template for PROJECT.
E           # Copyright (C) 2023 ORGANIZATION
E           # This file is distributed under the same license as the PROJECT project.
E           # FIRST AUTHOR <EMAIL@ADDRESS>, 2023.
E           #
E           #, fuzzy...
E         
E         ...Full output truncated (33 lines hidden), use '-vv' to show

/home/mrgreen/code/babel/tests/messages/test_frontend.py:1588: AssertionError
______________________ test_extract_ignore_dirs[True] ______________________

monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7febbeebbcd0>, capsys = <_pytest.capture.CaptureFixture object at 0x7febbeebb550>, tmp_path = PosixPath('/tmp/pytest-of-mrgreen/pytest-33/test_extract_ignore_dirs_True_0'), with_underscore_ignore = True

    @pytest.mark.parametrize("with_underscore_ignore", (False, True))
    def test_extract_ignore_dirs(monkeypatch, capsys, tmp_path, with_underscore_ignore):
        pot_file = tmp_path / 'temp.pot'
        monkeypatch.chdir(project_dir)
        cmd = f"extract . -o '{pot_file}' --ignore-dirs '*ignored* .*' "
        if with_underscore_ignore:
            # This also tests that multiple arguments are supported.
            cmd += "--ignore-dirs '_*'"
        cmdinst = configure_cli_command(cmd)
        assert isinstance(cmdinst, ExtractMessages)
        assert cmdinst.directory_filter
        cmdinst.run()
        pot_content = pot_file.read_text()
    
        # The `ignored` directory is now actually ignored:
>       assert 'this_wont_normally_be_here' not in pot_content
E       assert 'this_wont_normally_be_here' not in '# Translati...tr[1] ""\n\n'
E         'this_wont_normally_be_here' is contained here:
E           # Translations template for PROJECT.
E           # Copyright (C) 2023 ORGANIZATION
E           # This file is distributed under the same license as the PROJECT project.
E           # FIRST AUTHOR <EMAIL@ADDRESS>, 2023.
E           #
E           #, fuzzy...
E         
E         ...Full output truncated (29 lines hidden), use '-vv' to show

/home/mrgreen/code/babel/tests/messages/test_frontend.py:1588: AssertionError

After, function argument fix:

============= test session starts =============
platform linux -- Python 3.10.11, pytest-7.4.3, pluggy-1.3.0 -- /home/mrgreen/code/babel/venv/bin/python3
cachedir: .pytest_cache
rootdir: /home/mrgreen/code/babel
configfile: setup.cfg
plugins: cov-4.1.0
collected 60 items / 58 deselected / 2 selected                                                                                                                                                                                                                                                         

tests/messages/test_frontend.py::test_extract_ignore_dirs[False] 
ignore_dirs = ['*ignored*', '.*'] 
PASSED
tests/messages/test_frontend.py::test_extract_ignore_dirs[True] 
ignore_dirs = ['*ignored*', '.*', '_*'] 
PASSED