(self)
| 540 | assert_identical(expected, actual) |
| 541 | |
| 542 | def test_load(self) -> None: |
| 543 | # Note: please keep this in sync with test_load_async below as much as possible! |
| 544 | expected = create_test_data() |
| 545 | |
| 546 | @contextlib.contextmanager |
| 547 | def assert_loads(vars=None): |
| 548 | if vars is None: |
| 549 | vars = expected |
| 550 | with self.roundtrip(expected) as actual: |
| 551 | for k, v in actual.variables.items(): |
| 552 | # IndexVariables are eagerly loaded into memory |
| 553 | assert v._in_memory == (k in actual.dims) |
| 554 | yield actual |
| 555 | for k, v in actual.variables.items(): |
| 556 | if k in vars: |
| 557 | assert v._in_memory |
| 558 | assert_identical(expected, actual) |
| 559 | |
| 560 | with pytest.raises(AssertionError): |
| 561 | # make sure the contextmanager works! |
| 562 | with assert_loads() as ds: |
| 563 | pass |
| 564 | |
| 565 | with assert_loads() as ds: |
| 566 | ds.load() |
| 567 | |
| 568 | with assert_loads(["var1", "dim1", "dim2"]) as ds: |
| 569 | ds["var1"].load() |
| 570 | |
| 571 | # verify we can read data even after closing the file |
| 572 | with self.roundtrip(expected) as ds: |
| 573 | actual = ds.load() |
| 574 | assert_identical(expected, actual) |
| 575 | |
| 576 | @pytest.mark.asyncio |
| 577 | async def test_load_async(self) -> None: |
nothing calls this directly
no test coverage detected