GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Use Windows-safe cleanup for object-directory test · gitpython-developers/GitPython@553a70a

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test
    • test_repo.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/test_repo.py‎

Copy file name to clipboardExpand all lines: test/test_repo.py
+23-23Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -271,29 +271,29 @@ def test_repo_discovery_uses_storage_environment(self):
271271

272272
assert osp.samefile(Repo(git_dir).common_dir, byte_common_dir)
273273

274-
def test_repo_discovery_preserves_object_directory(self):
275-
with tempfile.TemporaryDirectory() as tdir:
276-
git_dir = Path(tdir) / "git"
277-
payload = b"custom object database"
278-
payload_file = Path(tdir) / "payload"
279-
payload_file.write_bytes(payload)
280-
281-
source_repo = Repo.init(git_dir, bare=True)
282-
blob_hexsha = source_repo.git.hash_object("-w", payload_file)
283-
source_repo.close()
284-
object_dir = Path(tdir) / "objects"
285-
(git_dir / "objects").rename(object_dir)
286-
287-
with cwd(tdir), mock.patch.dict(os.environ, {"GIT_DIR": "git", "GIT_OBJECT_DIRECTORY": "objects"}):
288-
repo = Repo(odbt=GitDB)
289-
290-
with repo:
291-
assert osp.samefile(repo.odb.root_path(), object_dir)
292-
assert repo.odb.has_object(bytes.fromhex(blob_hexsha))
293-
assert repo.git.cat_file("blob", blob_hexsha) == payload.decode()
294-
repo.alternates = ["other/location"]
295-
assert repo.alternates == ["other/location"]
296-
assert (object_dir / "info" / "alternates").is_file()
274+
@with_rw_directory
275+
def test_repo_discovery_preserves_object_directory(self, tdir):
276+
git_dir = Path(tdir) / "git"
277+
payload = b"custom object database"
278+
payload_file = Path(tdir) / "payload"
279+
payload_file.write_bytes(payload)
280+
281+
source_repo = Repo.init(git_dir, bare=True)
282+
blob_hexsha = source_repo.git.hash_object("-w", payload_file)
283+
source_repo.close()
284+
object_dir = Path(tdir) / "objects"
285+
(git_dir / "objects").rename(object_dir)
286+
287+
with cwd(tdir), mock.patch.dict(os.environ, {"GIT_DIR": "git", "GIT_OBJECT_DIRECTORY": "objects"}):
288+
repo = Repo(odbt=GitDB)
289+
290+
with repo:
291+
assert osp.samefile(repo.odb.root_path(), object_dir)
292+
assert repo.odb.has_object(bytes.fromhex(blob_hexsha))
293+
assert repo.git.cat_file("blob", blob_hexsha) == payload.decode()
294+
repo.alternates = ["other/location"]
295+
assert repo.alternates == ["other/location"]
296+
assert (object_dir / "info" / "alternates").is_file()
297297

298298
@with_rw_repo("0.3.2.1")
299299
def test_repo_creation_from_different_paths(self, rw_repo):

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.