From ad619a80acd1911a925a770ebb4a7e9119bf0a78 Mon Sep 17 00:00:00 2001 From: Mohamed Ajab Date: Wed, 25 Nov 2026 19:07:44 +0000 Subject: [PATCH] test: preserve original paths in match_files results Signed-off-by: Mohamed Ajab --- tests/test_05_pathspec.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_05_pathspec.py b/tests/test_05_pathspec.py index a19635b..e641dc3 100644 --- a/tests/test_05_pathspec.py +++ b/tests/test_05_pathspec.py @@ -263,6 +263,20 @@ class PathSpecTest(PathSpecMixin, TestCase): The :class:`PathSpecTest` class tests the :class:`.PathSpec` class. """ + def test_match_files_preserves_path_objects_and_duplicates(self): + files = [Path('a.txt'), Path('b.log'), Path('c.txt'), Path('a.txt')] + for sub_test in self.parameterize_from_lines('gitignore', ['*.txt']): + with sub_test() as spec: + for negate, expected in ( + (False, [files[0], files[2], files[3]]), + (True, [files[1]]), + ): + with self.subTest(negate=negate): + actual = list(spec.match_files(iter(files), negate=negate)) + self.assertEqual(actual, expected) + for result, original in zip(actual, expected): + self.assertIs(result, original) + def test_01_absolute_dir_paths_1(self): """ Tests that absolute paths will be properly normalized and matched.