code: def test_mongo_observer_saves_after_failure(
      failing_mongo_observer, sample_run
  ):
      failure_dir = "/tmp/my_failure/dir"
      failing_mongo_observer.failure_dir = failure_dir
      failing_mongo_observer.started_event(**sample_run)
  
      info = {"my_info": [1, 2, 3], "nr": 7}
      outp = "some output"
      failing_mongo_observer.heartbeat_event(
          info=info, captured_out=outp, beat_time=T2, result=1337
      )
  
      failing_mongo_observer.completed_event(stop_time=T3, result=42)
      glob_pattern = "{}/sacred_mongo_fail_{}*.pickle".format(
          failure_dir, sample_run["_id"]
      )
      os.path.isfile(glob(glob_pattern)[-1])
  
imports: import datetime
  import os
  import sys
  from glob import glob
  import mock
  import pytest
  from sacred.metrics_logger import ScalarMetricLogEntry, linearize_metrics
  import gridfs
  from mongomock.gridfs import enable_gridfs_integration
  from .failing_mongo_mock import FailingMongoClient
  from sacred.dependencies import get_digest
  from sacred.observers.mongo import MongoObserver, force_bson_encodeable
label_desc: Use image node_id 15 for calling a global function with example usage: test_mongo_observer_saves_after_failure(failing_mongo_observer, sample_run) without return types