diff options
author | Daniel Kutik <daniel.kutik@lavawerk.com> | 2023-08-15 15:59:07 +0200 |
---|---|---|
committer | LUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-09-13 18:24:04 +0000 |
commit | 880c621dc641e3b27233199f6cd3a9438fdf73ab (patch) | |
tree | a51ef770d6d1a0b6c03892ac2cc37e434d9c23ba /tests/test_subcmds_sync.py | |
parent | da6ae1da8b057220d6b14d684e35a7b08068c935 (diff) | |
download | git-repo-880c621dc641e3b27233199f6cd3a9438fdf73ab.tar.gz |
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 <vapier@google.com>
Commit-Queue: Daniel Kutik <daniel.kutik@lavawerk.com>
Tested-by: Daniel Kutik <daniel.kutik@lavawerk.com>
Diffstat (limited to 'tests/test_subcmds_sync.py')
-rw-r--r-- | tests/test_subcmds_sync.py | 8 |
1 files 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): | |||
117 | 117 | ||
118 | def setUp(self): | 118 | def setUp(self): |
119 | """Common setup.""" | 119 | """Common setup.""" |
120 | self.repodir = tempfile.mkdtemp(".repo") | 120 | self.topdir = tempfile.mkdtemp("LocalSyncState") |
121 | self.repodir = os.path.join(self.topdir, ".repo") | ||
122 | os.makedirs(self.repodir) | ||
123 | |||
121 | self.manifest = mock.MagicMock( | 124 | self.manifest = mock.MagicMock( |
125 | topdir=self.topdir, | ||
122 | repodir=self.repodir, | 126 | repodir=self.repodir, |
123 | repoProject=mock.MagicMock(relpath=".repo/repo"), | 127 | repoProject=mock.MagicMock(relpath=".repo/repo"), |
124 | ) | 128 | ) |
@@ -126,7 +130,7 @@ class LocalSyncState(unittest.TestCase): | |||
126 | 130 | ||
127 | def tearDown(self): | 131 | def tearDown(self): |
128 | """Common teardown.""" | 132 | """Common teardown.""" |
129 | shutil.rmtree(self.repodir) | 133 | shutil.rmtree(self.topdir) |
130 | 134 | ||
131 | def _new_state(self, time=_TIME): | 135 | def _new_state(self, time=_TIME): |
132 | with mock.patch("time.time", return_value=time): | 136 | with mock.patch("time.time", return_value=time): |