diff --git a/asdf/_tests/tags/core/tests/test_ndarray.py b/asdf/_tests/tags/core/tests/test_ndarray.py index 08a2202fe..d0f4b80ab 100644 --- a/asdf/_tests/tags/core/tests/test_ndarray.py +++ b/asdf/_tests/tags/core/tests/test_ndarray.py @@ -976,7 +976,7 @@ def test_memmap_write(tmp_path): tmpfile = str(tmp_path / "data.asdf") tree = {"data": np.zeros(100)} - with asdf.AsdfFile(tree) as af: + with asdf.AsdfFile(tree, memmap=False) as af: # Make sure we're actually writing to an internal array for this test af.write_to(tmpfile, all_array_storage="internal") @@ -1002,7 +1002,7 @@ def test_readonly(tmp_path): af.write_to(tmpfile, all_array_storage="internal") # Opening in read mode (the default) should mean array is readonly - with asdf.open(tmpfile) as af: + with asdf.open(tmpfile, memmap=True) as af: assert af["data"].flags.writeable is False with pytest.raises(ValueError, match=r"assignment destination is read-only"): af["data"][0] = 41 @@ -1046,7 +1046,7 @@ def test_block_data_change(pad_blocks, tmp_path): with asdf.AsdfFile(tree) as af: af.write_to(tmpfile, pad_blocks=pad_blocks) - with asdf.open(tmpfile, mode="rw") as af: + with asdf.open(tmpfile, mode="rw", memmap=True) as af: assert np.all(af.tree["data"] == 0) array_before = af.tree["data"].__array__() af.tree["data"][:5] = 1 diff --git a/asdf/_tests/test_api.py b/asdf/_tests/test_api.py index 2b95734f3..0819d2a08 100644 --- a/asdf/_tests/test_api.py +++ b/asdf/_tests/test_api.py @@ -61,7 +61,7 @@ def test_open_readonly(tmp_path): os.chmod(tmpfile, 0o440) assert os.access(tmpfile, os.W_OK) is False - with asdf.open(tmpfile) as af: + with asdf.open(tmpfile, memmap=True) as af: assert af["baz"].flags.writeable is False with pytest.raises(PermissionError, match=r".* Permission denied: .*"), asdf.open(tmpfile, mode="rw"): diff --git a/asdf/_tests/test_array_blocks.py b/asdf/_tests/test_array_blocks.py index e8d8cf3c4..e162e668d 100644 --- a/asdf/_tests/test_array_blocks.py +++ b/asdf/_tests/test_array_blocks.py @@ -811,9 +811,11 @@ def filename_with_array(tmp_path_factory): @pytest.mark.parametrize( "open_kwargs,should_memmap", [ - ({}, True), - ({"memmap": True}, True), - ({"memmap": False}, False), + ({}, False), + ({"lazy_load": True, "memmap": True}, True), + ({"lazy_load": False, "memmap": True}, True), + ({"lazy_load": True, "memmap": False}, False), + ({"lazy_load": False, "memmap": False}, False), ], ) def test_open_no_memmap(filename_with_array, open_kwargs, should_memmap): @@ -823,7 +825,7 @@ def test_open_no_memmap(filename_with_array, open_kwargs, should_memmap): default (no kwargs) memmap """ - with asdf.open(filename_with_array, lazy_load=False, **open_kwargs) as af: + with asdf.open(filename_with_array, **open_kwargs) as af: array = af.tree["array"] if should_memmap: assert isinstance(array.base, np.memmap) diff --git a/asdf/_tests/test_generic_io.py b/asdf/_tests/test_generic_io.py index fea00295f..25158b632 100644 --- a/asdf/_tests/test_generic_io.py +++ b/asdf/_tests/test_generic_io.py @@ -110,7 +110,7 @@ def get_read_fd(): f.read(0) return f - with _roundtrip(tree, get_write_fd, get_read_fd) as ff: + with _roundtrip(tree, get_write_fd, get_read_fd, read_options={"memmap": True}) as ff: assert len(ff._blocks.blocks) == 2 assert isinstance(ff._blocks.blocks[0].cached_data, np.memmap) @@ -133,7 +133,7 @@ def get_read_fd(): assert f._uri == path.as_uri() return f - with _roundtrip(tree, get_write_fd, get_read_fd) as ff: + with _roundtrip(tree, get_write_fd, get_read_fd, read_options={"memmap": True}) as ff: assert len(ff._blocks.blocks) == 2 assert isinstance(ff._blocks.blocks[0].cached_data, np.memmap) @@ -173,7 +173,7 @@ def get_read_fd(): assert f._uri == path.as_uri() return f - with _roundtrip(tree, get_write_fd, get_read_fd) as ff: + with _roundtrip(tree, get_write_fd, get_read_fd, read_options={"memmap": True}) as ff: assert len(ff._blocks.blocks) == 2 assert isinstance(ff._blocks.blocks[0].cached_data, np.memmap) ff.tree["science_data"][0] = 42 diff --git a/asdf/_tests/test_reference.py b/asdf/_tests/test_reference.py index 8cbfb16b0..9fd3d38a8 100644 --- a/asdf/_tests/test_reference.py +++ b/asdf/_tests/test_reference.py @@ -79,7 +79,7 @@ def do_asserts(ff): assert_array_equal(ff.tree["internal"], exttree["cool_stuff"]["a"]) - with asdf.AsdfFile({}, uri=(tmp_path / "main.asdf").as_uri()) as ff: + with asdf.AsdfFile({}, uri=(tmp_path / "main.asdf").as_uri(), memmap=True) as ff: # avoid passing tree to AsdfFile to avoid the deprecation warning, this can be updated # when automatic find_references on AsdfFile.__init__ is removed ff.tree = tree