(tmp_path)
| 27 | |
| 28 | |
| 29 | def test_truncated_file(tmp_path): |
| 30 | path = tmp_path / 'test.png' |
| 31 | path_t = tmp_path / 'test_truncated.png' |
| 32 | plt.savefig(path) |
| 33 | with open(path, 'rb') as fin: |
| 34 | buf = fin.read() |
| 35 | with open(path_t, 'wb') as fout: |
| 36 | fout.write(buf[:20]) |
| 37 | |
| 38 | with pytest.raises(Exception): |
| 39 | plt.imread(path_t) |
| 40 | |
| 41 | |
| 42 | def test_truncated_buffer(): |