From 880c621dc641e3b27233199f6cd3a9438fdf73ab Mon Sep 17 00:00:00 2001 From: Daniel Kutik Date: Tue, 15 Aug 2023 15:59:07 +0200 Subject: [PATCH] tests: test_subcmds_sync.py: fix for py3.6 & 3.7 tests/test_subcmds_sync.py::LocalSyncState::test_prune_removed_projects was failing in Python 3.6 and 3.7 due to topdir not being set with the following error message: TypeError: expected str, bytes or os.PathLike object, not MagicMock topdir is accessed from within PruneRemovedProjects(). Test: tox with Python 3.6 to 3.11 Change-Id: I7ba5144df0a0126c01776384e2178136c3510091 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/382816 Reviewed-by: Mike Frysinger Commit-Queue: Daniel Kutik Tested-by: Daniel Kutik --- tests/test_subcmds_sync.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/test_subcmds_sync.py b/tests/test_subcmds_sync.py index b9f0a746..71e40489 100644 --- a/tests/test_subcmds_sync.py +++ b/tests/test_subcmds_sync.py @@ -117,8 +117,12 @@ class LocalSyncState(unittest.TestCase): def setUp(self): """Common setup.""" - self.repodir = tempfile.mkdtemp(".repo") + self.topdir = tempfile.mkdtemp("LocalSyncState") + self.repodir = os.path.join(self.topdir, ".repo") + os.makedirs(self.repodir) + self.manifest = mock.MagicMock( + topdir=self.topdir, repodir=self.repodir, repoProject=mock.MagicMock(relpath=".repo/repo"), ) @@ -126,7 +130,7 @@ class LocalSyncState(unittest.TestCase): def tearDown(self): """Common teardown.""" - shutil.rmtree(self.repodir) + shutil.rmtree(self.topdir) def _new_state(self, time=_TIME): with mock.patch("time.time", return_value=time):