(monkeypatch)
| 185 | |
| 186 | @pytest.fixture |
| 187 | def open_logging_fs(monkeypatch): |
| 188 | from pyarrow.fs import LocalFileSystem, PyFileSystem |
| 189 | |
| 190 | from .test_fs import ProxyHandler |
| 191 | |
| 192 | localfs = LocalFileSystem() |
| 193 | |
| 194 | def normalized(paths): |
| 195 | return {localfs.normalize_path(str(p)) for p in paths} |
| 196 | |
| 197 | opened = set() |
| 198 | |
| 199 | def open_input_file(self, path): |
| 200 | path = localfs.normalize_path(str(path)) |
| 201 | opened.add(path) |
| 202 | return self._fs.open_input_file(path) |
| 203 | |
| 204 | # patch proxyhandler to log calls to open_input_file |
| 205 | monkeypatch.setattr(ProxyHandler, "open_input_file", open_input_file) |
| 206 | fs = PyFileSystem(ProxyHandler(localfs)) |
| 207 | |
| 208 | @contextlib.contextmanager |
| 209 | def assert_opens(expected_opened): |
| 210 | opened.clear() |
| 211 | try: |
| 212 | yield |
| 213 | finally: |
| 214 | assert normalized(opened) == normalized(expected_opened) |
| 215 | |
| 216 | return fs, assert_opens |
| 217 | |
| 218 | |
| 219 | @pytest.fixture(scope='module') |
nothing calls this directly
no test coverage detected