1313
1414
1515class FileObjTest (unittest .TestCase ):
16-
1716 def test_str (self ):
17+ self .assertEqual ("memory://test.zarr" , str (FileObj ("memory://test.zarr" )))
1818 self .assertEqual (
1919 "memory://test.zarr" ,
20- str (FileObj ("memory://test.zarr" ))
21- )
22- self .assertEqual (
23- "memory://test.zarr" ,
24- str (FileObj ("memory://test.zarr" ,
25- storage_options = dict (asynchronous = False )))
20+ str (
21+ FileObj ("memory://test.zarr" , storage_options = dict (asynchronous = False ))
22+ ),
2623 )
2724
2825 def test_repr (self ):
2926 self .assertEqual (
30- "FileObj('memory://test.zarr')" ,
31- repr (FileObj ("memory://test.zarr" ))
27+ "FileObj('memory://test.zarr')" , repr (FileObj ("memory://test.zarr" ))
3228 )
3329 self .assertEqual (
34- "FileObj('memory://test.zarr',"
35- " storage_options={'asynchronous': False})" ,
36- repr ( FileObj ("memory://test.zarr" ,
37- storage_options = dict ( asynchronous = False )))
30+ "FileObj('memory://test.zarr'," " storage_options={'asynchronous': False})" ,
31+ repr (
32+ FileObj ("memory://test.zarr" , storage_options = dict ( asynchronous = False ))
33+ ),
3834 )
3935
4036 def test_memory_protocol (self ):
@@ -51,17 +47,15 @@ def test_file_protocol(self):
5147 self .assertEqual (None , zarr_dir .storage_options )
5248 self .assertIsInstance (zarr_dir .fs , fsspec .AbstractFileSystem )
5349 self .assertEqual ("file" , to_protocol (zarr_dir .fs ))
54- self .assertEqual (os .path .abspath ("test.zarr" ).replace ("\\ " , "/" ),
55- zarr_dir .path )
50+ self .assertEqual (os .path .abspath ("test.zarr" ).replace ("\\ " , "/" ), zarr_dir .path )
5651
5752 def test_local_protocol (self ):
5853 zarr_dir = FileObj ("test.zarr" )
5954 self .assertEqual ("test.zarr" , zarr_dir .uri )
6055 self .assertEqual (None , zarr_dir .storage_options )
6156 self .assertIsInstance (zarr_dir .fs , fsspec .AbstractFileSystem )
6257 self .assertEqual ("file" , to_protocol (zarr_dir .fs ))
63- self .assertEqual (os .path .abspath ("test.zarr" ).replace ("\\ " , "/" ),
64- zarr_dir .path )
58+ self .assertEqual (os .path .abspath ("test.zarr" ).replace ("\\ " , "/" ), zarr_dir .path )
6559
6660 def test_s3_protocol (self ):
6761 zarr_dir = FileObj ("s3://eo-data/test.zarr" )
@@ -87,19 +81,22 @@ def test_truediv_override(self):
8781 root = FileObj ("s3://eo-data/test.zarr" )
8882
8983 derived = root / ""
90- self .assert_derived_ok (root , derived ,
91- "s3://eo-data/test.zarr" ,
92- "eo-data/test.zarr" )
84+ self .assert_derived_ok (
85+ root , derived , "s3://eo-data/test.zarr" , "eo-data/test.zarr"
86+ )
9387
9488 derived = root / ".zgroup"
95- self .assert_derived_ok (root , derived ,
96- "s3://eo-data/test.zarr/.zgroup" ,
97- "eo-data/test.zarr/.zgroup" )
89+ self .assert_derived_ok (
90+ root , derived , "s3://eo-data/test.zarr/.zgroup" , "eo-data/test.zarr/.zgroup"
91+ )
9892
9993 derived = root / "chl" / ".zarray"
100- self .assert_derived_ok (root , derived ,
101- "s3://eo-data/test.zarr/chl/.zarray" ,
102- "eo-data/test.zarr/chl/.zarray" )
94+ self .assert_derived_ok (
95+ root ,
96+ derived ,
97+ "s3://eo-data/test.zarr/chl/.zarray" ,
98+ "eo-data/test.zarr/chl/.zarray" ,
99+ )
103100
104101 def test_parent (self ):
105102 file = FileObj ("s3://eo-data/test.zarr/.zmetadata" )
@@ -123,8 +120,7 @@ def test_parent(self):
123120 self .assertEqual ("" , parent .path )
124121 self .assertIs (fs , parent .fs )
125122
126- with pytest .raises (ValueError ,
127- match = "cannot get parent of empty path" ):
123+ with pytest .raises (ValueError , match = "cannot get parent of empty path" ):
128124 # noinspection PyUnusedLocal
129125 parent = parent .parent
130126
@@ -134,8 +130,9 @@ def test_parent(self):
134130 parent = file .parent
135131 self .assertIsInstance (parent , FileObj )
136132 self .assertEqual ("test.zarr/chl" , parent .uri )
137- self .assertEqual (os .path .abspath ("test.zarr/chl" ).replace ("\\ " , "/" ),
138- parent .path )
133+ self .assertEqual (
134+ os .path .abspath ("test.zarr/chl" ).replace ("\\ " , "/" ), parent .path
135+ )
139136 self .assertIs (fs , parent .fs )
140137
141138 def test_parent_with_chained_uri (self ):
@@ -153,35 +150,34 @@ def test_parent_with_chained_uri(self):
153150 parent = file .parent
154151 self .assertIsInstance (parent , FileObj )
155152 self .assertEqual ("test.zarr/chl::/eo-data/test.zarr" , parent .uri )
156- self .assertEqual (os .path .abspath ("test.zarr/chl" ).replace ("\\ " , "/" ),
157- parent .path )
153+ self .assertEqual (
154+ os .path .abspath ("test.zarr/chl" ).replace ("\\ " , "/" ), parent .path
155+ )
158156 self .assertIs (fs , parent .fs )
159157
160158 def test_for_path (self ):
161159 root = FileObj ("s3://eo-data/test.zarr" )
162160
163161 derived = root .for_path ("" )
164- self .assert_derived_ok (root , derived ,
165- "s3://eo-data/test.zarr" ,
166- "eo-data/test.zarr" )
162+ self .assert_derived_ok (
163+ root , derived , "s3://eo-data/test.zarr" , "eo-data/test.zarr"
164+ )
167165
168166 derived = root .for_path (".zgroup" )
169- self .assert_derived_ok (root , derived ,
170- "s3://eo-data/test.zarr/.zgroup" ,
171- "eo-data/test.zarr/.zgroup" )
167+ self .assert_derived_ok (
168+ root , derived , "s3://eo-data/test.zarr/.zgroup" , "eo-data/test.zarr/.zgroup"
169+ )
172170
173171 def test_for_path_with_chained_uri (self ):
174172 root = FileObj ("dir://chl::file:/eo-data/test.zarr" )
175173 derived = root .for_path (".zarray" )
176- self .assert_derived_ok (root , derived ,
177- "dir://chl/.zarray::file:/eo-data/test.zarr" ,
178- "chl/.zarray" )
179-
180- def assert_derived_ok (self ,
181- root : FileObj ,
182- derived : FileObj ,
183- expected_uri : str ,
184- expected_path : str ):
174+ self .assert_derived_ok (
175+ root , derived , "dir://chl/.zarray::file:/eo-data/test.zarr" , "chl/.zarray"
176+ )
177+
178+ def assert_derived_ok (
179+ self , root : FileObj , derived : FileObj , expected_uri : str , expected_path : str
180+ ):
185181 self .assertEqual (expected_uri , derived .uri )
186182 self .assertEqual (expected_path , derived .path )
187183 self .assertIs (root .fs , derived .fs )
0 commit comments