(tmpdir)
| 345 | |
| 346 | |
| 347 | def test_python_file_writelines(tmpdir): |
| 348 | lines = [b'line1\n', b'line2\n' b'line3'] |
| 349 | path = os.path.join(str(tmpdir), 'foo.txt') |
| 350 | with open(path, 'wb') as f: |
| 351 | try: |
| 352 | f = pa.PythonFile(f, mode='w') |
| 353 | assert f.writable() |
| 354 | f.writelines(lines) |
| 355 | finally: |
| 356 | f.close() |
| 357 | |
| 358 | with open(path, 'rb') as f: |
| 359 | try: |
| 360 | f = pa.PythonFile(f, mode='r') |
| 361 | assert f.readable() |
| 362 | assert f.read() == b''.join(lines) |
| 363 | finally: |
| 364 | f.close() |
| 365 | |
| 366 | |
| 367 | def test_python_file_closing(): |
nothing calls this directly
no test coverage detected