docstr: Test that bootstrap.run sets the matplotlib backend to
  "Agg" if config.runner.fixMatplotlib=True.
docstr_tok: ["Test","that","bootstrap.run","sets","the","matplotlib","backend","to","''","Agg","''","if","config.runner.fixMatplotlib=True","."]
code: def test_fix_matplotlib_crash(self):
      """Test that bootstrap.run sets the matplotlib backend to
      "Agg" if config.runner.fixMatplotlib=True.
      """
      # TODO: Find a proper way to mock sys.platform
      ORIG_PLATFORM = sys.platform
  
      for platform, do_fix in [("darwin", True), ("linux2", True)]:
          sys.platform = platform
  
          matplotlib.use("pdf", force=True)
  
          config._set_option("runner.fixMatplotlib", True, "test")
          bootstrap.run("/not/a/script", "", [], {})
          if do_fix:
              self.assertEqual("agg", matplotlib.get_backend().lower())
          else:
              self.assertEqual("pdf", matplotlib.get_backend().lower())
  
          # Reset
          matplotlib.use("pdf", force=True)
  
          config._set_option("runner.fixMatplotlib", False, "test")
          bootstrap.run("/not/a/script", "", [], {})
          self.assertEqual("pdf", matplotlib.get_backend().lower())
  
      sys.platform = ORIG_PLATFORM
  
imports: import os.path
  import sys
  import unittest
  from io import StringIO
  from unittest import IsolatedAsyncioTestCase
  from unittest.mock import Mock, patch
  import matplotlib
  import pytest
  from streamlit import config
  from streamlit.web import bootstrap
  from streamlit.web.bootstrap import NEW_VERSION_TEXT, _fix_pydantic_duplicate_validators_error
  from tests import testutil
  from tests.testutil import patch_config_options, should_skip_pydantic_tests
label_desc: Use image node_id 1 for calling the BootstrapTest obj's underlying member method code with example usage: obj.test_fix_matplotlib_crash() without return types