| 112 | |
| 113 | |
| 114 | def test_ops_blocksize(dir_server): |
| 115 | fn = files[0] |
| 116 | f = open_files(root + fn, block_size=2)[0] |
| 117 | with open(os.path.join(dir_server, fn), "rb") as expected: |
| 118 | expected = expected.read() |
| 119 | with f as f: |
| 120 | # it's OK to read the whole file |
| 121 | assert f.read() == expected |
| 122 | # and now the file magically has a size |
| 123 | assert f.size == len(expected) |
| 124 | |
| 125 | # note that if we reuse f from above, because it is tokenized, we get |
| 126 | # the same open file - where is this cached? |
| 127 | fn = files[1] |
| 128 | f = open_files(root + fn, block_size=2)[0] |
| 129 | with f as f: |
| 130 | if Version(fsspec.__version__) < Version("2021.11.1"): |
| 131 | # fails because we want only 12 bytes |
| 132 | with pytest.raises(ValueError): |
| 133 | assert f.read(10) == expected[:10] |
| 134 | else: |
| 135 | # fixed in https://github.com/fsspec/filesystem_spec/pull/830 |
| 136 | assert f.read(10) == expected[:10] |
| 137 | |
| 138 | |
| 139 | def test_errors(dir_server): |