(self)
| 398 | |
| 399 | class TestCommon: |
| 400 | def test_robust_getitem(self) -> None: |
| 401 | class UnreliableArrayFailure(Exception): |
| 402 | pass |
| 403 | |
| 404 | class UnreliableArray: |
| 405 | def __init__(self, array, failures=1): |
| 406 | self.array = array |
| 407 | self.failures = failures |
| 408 | |
| 409 | def __getitem__(self, key): |
| 410 | if self.failures > 0: |
| 411 | self.failures -= 1 |
| 412 | raise UnreliableArrayFailure |
| 413 | return self.array[key] |
| 414 | |
| 415 | array = UnreliableArray([0]) |
| 416 | with pytest.raises(UnreliableArrayFailure): |
| 417 | array[0] |
| 418 | assert array[0] == 0 |
| 419 | |
| 420 | actual = robust_getitem(array, 0, catch=UnreliableArrayFailure, initial_delay=0) |
| 421 | assert actual == 0 |
| 422 | |
| 423 | |
| 424 | class NetCDF3Only: |
nothing calls this directly
no test coverage detected