code: def test_check_events_errors():
      """Test the function which tests that the events
      data describes a valid experimental paradigm.
      """
      events = basic_paradigm()
      # Errors checkins
      # Wrong type
      with pytest.raises(
          TypeError, match="Events should be a Pandas DataFrame."
      ):
          check_events([])
  
      # Missing onset
      missing_onset = events.drop(columns=["onset"])
      with pytest.raises(
          ValueError,
          match="The provided events data has no onset column.",
      ):
          check_events(missing_onset)
  
      # Missing duration
      missing_duration = events.drop(columns=["duration"])
      with pytest.raises(
          ValueError,
          match="The provided events data has no duration column.",
      ):
          check_events(missing_duration)
  
      # Duration wrong type
      wrong_duration = events.copy()
      wrong_duration["duration"] = "foo"
      with pytest.raises(
          ValueError, match="Could not cast duration to float"
      ):
          check_events(wrong_duration)
  
file_path: nilearn/nilearn/glm/tests/test_paradigm.py
imports: import os
  import numpy
  import pandas
  import pytest
  from numpy.testing import assert_array_equal
  from nilearn._utils.data_gen import basic_paradigm
  from nilearn.glm.first_level.experimental_paradigm import check_events, handle_modulation_of_duplicate_events
  from ._testing import block_paradigm, design_with_nan_durations, design_with_nan_onsets, design_with_null_durations, duplicate_events_paradigm, modulated_block_paradigm, modulated_event_paradigm
label_desc: Use image node_id 2 for calling a global function with example usage: test_check_events_errors() without return types