MCPcopy Create free account
hub / github.com/libgit2/pygit2 / TemporaryRepository

Class TemporaryRepository

test/utils.py:118–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116
117
118class TemporaryRepository:
119 def __init__(self, name: str, tmp_path: Path) -> None:
120 self.name = name
121 self.tmp_path = tmp_path
122
123 def __enter__(self) -> Path:
124 path = Path(__file__).parent / 'data' / self.name
125 temp_repo_path = Path(self.tmp_path) / path.stem
126 if path.suffix == '.zip':
127 with zipfile.ZipFile(path) as zipf:
128 zipf.extractall(self.tmp_path)
129 elif path.suffix == '.git':
130 shutil.copytree(path, temp_repo_path)
131 else:
132 raise ValueError(f'Unexpected {path.suffix} extension')
133
134 return temp_repo_path
135
136 def __exit__(
137 self,
138 exc_type: Optional[type[BaseException]],
139 exc_value: Optional[BaseException],
140 traceback: Optional[TracebackType],
141 ) -> None:
142 pass
143
144
145def assertRaisesWithArg(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…