code: def test_edf_data_broken(tmp_path):
      """Test edf files."""
      raw = _test_raw_reader(
          read_raw_edf,
          input_fname=edf_path,
          exclude=["Ergo-Left", "H10"],
          verbose="error",
      )
      raw_py = read_raw_edf(edf_path)
      data = raw_py.get_data()
      assert_equal(len(raw.ch_names) + 2, len(raw_py.ch_names))
  
      # Test with number of records not in header (-1).
      broken_fname = tmp_path / "broken.edf"
      with open(edf_path, "rb") as fid_in:
          fid_in.seek(0, 2)
          n_bytes = fid_in.tell()
          fid_in.seek(0, 0)
          rbytes = fid_in.read()
      with open(broken_fname, "wb") as fid_out:
          fid_out.write(rbytes[:236])
          fid_out.write(b"-1      ")
          fid_out.write(rbytes[244 : 244 + int(n_bytes * 0.4)])
      with pytest.warns(
          RuntimeWarning, match="records .* not match the file size"
      ):
          raw = read_raw_edf(broken_fname, preload=True)
          read_raw_edf(
              broken_fname, exclude=raw.ch_names[:132], preload=True
          )
  
      # Test with \x00's in the data
      with open(broken_fname, "wb") as fid_out:
          fid_out.write(rbytes[:184])
          assert rbytes[184:192] == b"36096   "
          fid_out.write(rbytes[184:192].replace(b" ", b"\x00"))
          fid_out.write(rbytes[192:])
      raw_py = read_raw_edf(broken_fname)
      data_new = raw_py.get_data()
      assert_allclose(data, data_new)
  
imports: import datetime
  from contextlib import nullcontext
  from functools import partial
  from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_array_equal, assert_equal
  from scipy.io import loadmat
  from mne import Annotations, pick_types
  from mne._fiff.pick import channel_indices_by_type, get_channel_type_constants
  from mne.annotations import _ndarray_ch_names, events_from_annotations, read_annotations
  from mne.datasets import testing
  from mne.io import edf, read_raw_bdf, read_raw_edf, read_raw_fif, read_raw_gdf
  from mne.io.edf.edf import _edf_str, _parse_prefilter_string, _read_annotations_edf, _read_ch, _read_edf_header, _read_header
  from mne.io.tests.test_raw import _test_raw_reader
  from mne.tests.test_annotations import _assert_annotations_equal
label_desc: Use image node_id 9 for calling a global function with example usage: test_edf_data_broken(tmp_path) without return types