Path: blob/master/tests/test_pre_commit_copyright.py
4255 views
import pytest1from unittest.mock import patch23from Tools.gittools.pre_commit_copyright import get_file_paths456def test_get_file_paths_no_args():7"""Test get_file_paths with no command line arguments."""8with patch('sys.argv', ["pre_commit_copyright.py"]):9with pytest.raises(SystemExit, match="2"):10_ = get_file_paths()111213@pytest.mark.parametrize(14"argv, expected",15[16(17["pre_commit_copyright.py", "file1.py", "file2.py", "file3.py"],18["file1.py", "file2.py", "file3.py"]19),20(21["pre_commit_copyright.py", "file1.py", "file2.py", "--ignore=file2.py"],22["file1.py"]23),24(25["pre_commit_copyright.py", "file1.py", "file2.py", "file3.py", "--ignore=file1.py", "--ignore=file3.py"],26["file2.py"]27),28(29["pre_commit_copyright.py", "file1.py", "file2.py", "--ignore=excluded_file.py", "--ignore=another_excluded.py"],30["file1.py", "file2.py"]31),32(33["pre_commit_copyright.py", "file1.py", "--ignore=file1.py"],34[]35),36]37)38def test_get_file_paths_parametrized(argv, expected):39"""Test get_file_paths with various command line argument combinations."""40with patch('sys.argv', argv):41assert get_file_paths() == expected424344