code: def test_force_bson_encodable_substitutes_illegal_value_with_strings():
      d = {
          "a_module": datetime,
          "some_legal_stuff": {"foo": "bar", "baz": [1, 23, 4]},
          "nested": {"dict": {"with": {"illegal_module": mock}}},
          "$illegal": "because it starts with a $",
          "il.legal": "because it contains a .",
          12.7: "illegal because it is not a string key",
      }
      expected = {
          "a_module": str(datetime),
          "some_legal_stuff": {"foo": "bar", "baz": [1, 23, 4]},
          "nested": {"dict": {"with": {"illegal_module": str(mock)}}},
          "@illegal": "because it starts with a $",
          "il,legal": "because it contains a .",
          "12,7": "illegal because it is not a string key",
      }
      assert force_bson_encodeable(d) == expected
  
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 22 for calling a global function with example usage: test_force_bson_encodable_substitutes_illegal_value_with_strings() without return types