MCPcopy Create free account
hub / github.com/apache/arrow / test_output_stream_duck_typing

Function test_output_stream_duck_typing

python/pyarrow/tests/test_io.py:2084–2103  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2082
2083
2084def test_output_stream_duck_typing():
2085 # Accept objects having the right file-like methods...
2086 class DuckWriter:
2087 def __init__(self):
2088 self.buf = pa.BufferOutputStream()
2089
2090 def close(self):
2091 pass
2092
2093 @property
2094 def closed(self):
2095 return False
2096
2097 def write(self, data):
2098 self.buf.write(data)
2099
2100 duck_writer = DuckWriter()
2101 stream = pa.output_stream(duck_writer)
2102 assert stream.write(b'hello')
2103 assert duck_writer.buf.getvalue().to_pybytes() == b'hello'
2104
2105
2106def test_output_stream_file_path(tmpdir):

Callers

nothing calls this directly

Calls 2

DuckWriterClass · 0.85
writeMethod · 0.45

Tested by

no test coverage detected