MCPcopy Index your code
hub / github.com/pydata/xarray / byte_attrs_dataset

Function byte_attrs_dataset

xarray/tests/conftest.py:177–193  ·  view source on GitHub ↗

For testing issue #9407

()

Source from the content-addressed store, hash-verified

175
176@pytest.fixture
177def 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")

Callers

nothing calls this directly

Calls 3

copyMethod · 0.95
DatasetClass · 0.90
decodeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…