(tmpdir)
| 321 | |
| 322 | |
| 323 | def test_python_file_implicit_mode(tmpdir): |
| 324 | path = os.path.join(str(tmpdir), 'foo.txt') |
| 325 | with open(path, 'wb') as f: |
| 326 | pf = pa.PythonFile(f) |
| 327 | assert pf.writable() |
| 328 | assert not pf.readable() |
| 329 | assert not pf.seekable() # PyOutputStream isn't seekable |
| 330 | f.write(b'foobar\n') |
| 331 | |
| 332 | with open(path, 'rb') as f: |
| 333 | pf = pa.PythonFile(f) |
| 334 | assert pf.readable() |
| 335 | assert not pf.writable() |
| 336 | assert pf.seekable() |
| 337 | assert pf.read() == b'foobar\n' |
| 338 | |
| 339 | bio = BytesIO() |
| 340 | pf = pa.PythonFile(bio) |
| 341 | assert pf.writable() |
| 342 | assert not pf.readable() |
| 343 | assert not pf.seekable() |
| 344 | pf.write(b'foobar\n') |
| 345 | assert bio.getvalue() == b'foobar\n' |
| 346 | |
| 347 | |
| 348 | def test_python_file_writelines(tmpdir): |
nothing calls this directly
no test coverage detected