code: def test_passing_kwds():
      # Check that we correctly pass keywords to dicom
      dwi_glob = "siemens_dwi_*.dcm.gz"
      csa_glob = "csa*.bin"
      for func in (didr.read_mosaic_dwi_dir, didr.read_mosaic_dir):
          data, aff, bs, gs = func(IO_DATA_PATH, dwi_glob)
          # This should not raise an error
          data2, aff2, bs2, gs2 = func(
              IO_DATA_PATH, dwi_glob, dicom_kwargs=dict(force=True)
          )
          assert_array_equal(data, data2)
          # This should raise an error in pydicom.filereader.dcmread
          with pytest.raises(TypeError):
              func(
                  IO_DATA_PATH,
                  dwi_glob,
                  dicom_kwargs=dict(not_a_parameter=True),
              )
          # These are invalid dicoms, so will raise an error unless force=True
          with pytest.raises(pydicom.filereader.InvalidDicomError):
              func(IO_DATA_PATH, csa_glob)
          # But here, we catch the error because the dicoms are in the wrong
          # format
          with pytest.raises(didr.DicomReadError):
              func(
                  IO_DATA_PATH, csa_glob, dicom_kwargs=dict(force=True)
              )
  
file_path: nibabel/nibabel/nicom/tests/test_dicomreaders.py
imports: from os.path import join
  import numpy
  import pytest
  from numpy.testing import assert_array_almost_equal, assert_array_equal
  from nibabel.optpkg import optional_package
  from ..None import dicomreaders
  from .test_dicomwrappers import DATA, EXPECTED_AFFINE, EXPECTED_PARAMS, IO_DATA_PATH
label_desc: Use image node_id 3 for calling a global function with example usage: test_passing_kwds() without return types