code: def test_run_emits_events_if_interrupted(run, exception, status):
      observer = run.observers[0]
      run.main_function.side_effect = exception
      with pytest.raises(exception):
          run()
      assert observer.started_event.called
      assert observer.heartbeat_event.called
      assert not observer.completed_event.called
      assert observer.interrupted_event.called
      observer.interrupted_event.assert_called_with(
          interrupt_time=run.stop_time, status=status
      )
      assert not observer.failed_event.called
  
imports: from datetime import datetime
  import mock
  import os
  import pytest
  import tempfile
  import sys
  from sacred.run import Run
  from sacred.config.config_summary import ConfigSummary
  from sacred.utils import ObserverError, SacredInterrupt, TimeoutInterrupt, apply_backspaces_and_linefeeds
label_desc: Use image node_id 6 for calling a global function with example usage: test_run_emits_events_if_interrupted(run, exception, status) without return types