| 116 | |
| 117 | |
| 118 | class 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 | |
| 145 | def assertRaisesWithArg( |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…