@@ -72,12 +72,13 @@ def test_virtualize_multi_granule_no_concat_dim_raises() -> None:
7272 """virtualize() raises ValueError for >1 granule without concat_dim."""
7373 from earthaccess .virtual .core import virtualize
7474
75- with patch (
76- "earthaccess.virtual.core.build_obstore_registry" ,
77- return_value = MagicMock (),
75+ with (
76+ patch (
77+ "earthaccess.virtual.core.build_obstore_registry" , return_value = MagicMock (),
78+ ),
79+ pytest .raises (ValueError , match = "concat_dim" ),
7880 ):
79- with pytest .raises (ValueError , match = "concat_dim" ):
80- virtualize (_make_granules (2 ))
81+ virtualize (_make_granules (2 ))
8182
8283
8384def test_virtualize_invalid_parser_string_raises () -> None :
@@ -99,9 +100,12 @@ def test_virtualize_load_false_returns_virtual_dataset() -> None:
99100
100101 mock_vds = MagicMock ()
101102 reg_patch , open_patch = _patch_internals (mock_vds )
102- with reg_patch , open_patch :
103- with patch ("earthaccess.virtual.core._load_via_kerchunk" ) as mock_load :
104- result = virtualize (_make_granules (1 ), load = False )
103+ with (
104+ reg_patch ,
105+ open_patch ,
106+ patch ("earthaccess.virtual.core._load_via_kerchunk" ) as mock_load ,
107+ ):
108+ result = virtualize (_make_granules (1 ), load = False )
105109
106110 assert result is mock_vds
107111 mock_load .assert_not_called ()
@@ -113,16 +117,18 @@ def test_virtualize_load_true_delegates_to_kerchunk(tmp_path) -> None:
113117
114118 expected_ds = MagicMock ()
115119 reg_patch , open_patch = _patch_internals ()
116- with reg_patch , open_patch :
117- with patch (
118- "earthaccess.virtual.core._load_via_kerchunk" ,
119- return_value = expected_ds ,
120- ) as mock_load :
121- result = virtualize (
122- _make_granules (1 ),
123- load = True ,
124- reference_dir = str (tmp_path ),
125- )
120+ with (
121+ reg_patch ,
122+ open_patch ,
123+ patch (
124+ "earthaccess.virtual.core._load_via_kerchunk" , return_value = expected_ds ,
125+ ) as mock_load ,
126+ ):
127+ result = virtualize (
128+ _make_granules (1 ),
129+ load = True ,
130+ reference_dir = str (tmp_path ),
131+ )
126132
127133 mock_load .assert_called_once ()
128134 assert result is expected_ds
@@ -146,16 +152,18 @@ def side_effect(*args, **kwargs):
146152 raise FileNotFoundError ("no .dmrpp sidecar" )
147153 return mock_vds_hdf
148154
149- with patch (
150- "earthaccess.virtual.core.build_obstore_registry" ,
151- return_value = MagicMock (),
152- ):
153- with patch (
155+ with (
156+ patch (
157+ "earthaccess.virtual.core.build_obstore_registry" ,
158+ return_value = MagicMock (),
159+ ),
160+ patch (
154161 "earthaccess.virtual.core._open_virtual_mfdataset" ,
155162 side_effect = side_effect ,
156- ):
157- with pytest .warns (UserWarning , match = "HDFParser" ):
158- result = virtualize (_make_granules (1 ), parser = "DMRPPParser" )
163+ ),
164+ pytest .warns (UserWarning , match = "HDFParser" ),
165+ ):
166+ result = virtualize (_make_granules (1 ), parser = "DMRPPParser" )
159167
160168 assert result is mock_vds_hdf
161169 assert call_count ["n" ] == 2
0 commit comments