For testing issue #9407
()
| 175 | |
| 176 | @pytest.fixture |
| 177 | def byte_attrs_dataset(): |
| 178 | """For testing issue #9407""" |
| 179 | null_byte = b"\x00" |
| 180 | other_bytes = bytes(range(1, 256)) |
| 181 | ds = Dataset({"x": 1}, coords={"x_coord": [1]}) |
| 182 | ds["x"].attrs["null_byte"] = null_byte |
| 183 | ds["x"].attrs["other_bytes"] = other_bytes |
| 184 | |
| 185 | expected = ds.copy() |
| 186 | expected["x"].attrs["null_byte"] = "" |
| 187 | expected["x"].attrs["other_bytes"] = other_bytes.decode(errors="replace") |
| 188 | |
| 189 | return { |
| 190 | "input": ds, |
| 191 | "expected": expected, |
| 192 | "h5netcdf_error": r"Invalid value provided for attribute .*: .*\. Null characters .*", |
| 193 | } |
| 194 | |
| 195 | |
| 196 | @pytest.fixture(scope="module") |