File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,11 @@ def wrapper(*args, **kwargs):
6060
6161 return wrapper
6262
63+ # We need to explicitly implement `__iter__`
64+ # because otherwise python iteration logic could use `__getitem__`
65+ def __iter__ (self ):
66+ return iter (self ._obj )
67+
6368 def __getitem__ (self , key ):
6469 # Intercept item access
6570 return self ._obj [key ]
Original file line number Diff line number Diff line change @@ -215,6 +215,15 @@ def test_read_write(self, target):
215215 assert o .open ("rb" ).read () == b"foo"
216216 o .unlink ()
217217
218+ def test_read_line_by_line (self , target ):
219+ o = ObjectStoragePath (f"file://{ target } " )
220+ with o .open ("wb" ) as f :
221+ f .write (b"foo\n bar\n " )
222+ with o .open ("rb" ) as f :
223+ lines = list (f )
224+ assert lines == [b"foo\n " , b"bar\n " ]
225+ o .unlink ()
226+
218227 def test_stat (self , target ):
219228 o = ObjectStoragePath (f"file://{ target } " )
220229 assert o .stat ().st_size == 0
You can’t perform that action at this time.
0 commit comments