From 2bdc9dcc1fdf0c178cce2ecfb9216b2319156cef Mon Sep 17 00:00:00 2001 From: Daniel D'Avella Date: Thu, 26 Oct 2023 20:29:48 -0400 Subject: [PATCH] Dependency ChangeSet should be relative to parent path --- src/codemodder/dependency_manager.py | 6 +++++- tests/test_dependency_manager.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/codemodder/dependency_manager.py b/src/codemodder/dependency_manager.py index b83d224c..af41ead2 100644 --- a/src/codemodder/dependency_manager.py +++ b/src/codemodder/dependency_manager.py @@ -60,7 +60,11 @@ def write(self, dry_run: bool = False) -> Optional[ChangeSet]: f.writelines([f"{line}\n" for line in self.new_requirements]) self.dependency_file_changed = True - return ChangeSet(str(self.dependency_file), diff, changes=changes) + return ChangeSet( + str(self.dependency_file.relative_to(self.parent_directory)), + diff, + changes=changes, + ) @property def found_dependency_file(self) -> bool: diff --git a/tests/test_dependency_manager.py b/tests/test_dependency_manager.py index c8757689..62a2bd06 100644 --- a/tests/test_dependency_manager.py +++ b/tests/test_dependency_manager.py @@ -36,7 +36,7 @@ def test_add_dependency_preserve_comments(self, tmpdir, dry_run): ) assert changeset is not None - assert changeset.path == str(dependency_file) + assert changeset.path == dependency_file.name assert changeset.diff == ( "--- \n" "+++ \n"