Browse Source

Add cleanup for unclosed Repo objects in test_client

Jelmer Vernooij 2 weeks ago
parent
commit
c65b632df1
1 changed files with 2 additions and 0 deletions
  1. 2 0
      tests/compat/test_client.py

+ 2 - 0
tests/compat/test_client.py

@@ -214,6 +214,7 @@ class DulwichClientTestBase:
     def disable_ff_and_make_dummy_commit(self):
         # disable non-fast-forward pushes to the server
         dest = repo.Repo(os.path.join(self.gitroot, "dest"))
+        self.addCleanup(dest.close)
         run_git_or_fail(
             ["config", "receive.denyNonFastForwards", "true"], cwd=dest.path
         )
@@ -296,6 +297,7 @@ class DulwichClientTestBase:
     def test_fetch_pack_with_nondefault_symref(self) -> None:
         c = self._client()
         src = repo.Repo(os.path.join(self.gitroot, "server_new.export"))
+        self.addCleanup(src.close)
         src.refs.add_if_new(b"refs/heads/main", src.refs[b"refs/heads/master"])
         src.refs.set_symbolic_ref(b"HEAD", b"refs/heads/main")
         with repo.Repo(os.path.join(self.gitroot, "dest")) as dest: