code: def test_streamlit_start_stop_server(subprocess_mock):
      """Test that `ServeStreamlit.run()` invokes subprocess.Popen with the right parameters."""
      work = ServeStreamlitTest()
      work._name = "test_work"
      work._host = "hostname"
      work._port = 1111
  
      work.run()
  
      subprocess_mock.Popen.assert_called_once()
  
      env_variables = subprocess_mock.method_calls[0].kwargs["env"]
      call_args = subprocess_mock.method_calls[0].args[0]
      assert call_args == [
          sys.executable,
          "-m",
          "streamlit",
          "run",
          lightning.app.components.serve.streamlit.__file__,
          "--server.address",
          "hostname",
          "--server.port",
          "1111",
          "--server.headless",
          "true",
      ]
  
      assert env_variables["LIGHTNING_COMPONENT_NAME"] == "test_work"
      assert env_variables["LIGHTNING_WORK"] == "ServeStreamlitTest"
      assert env_variables["LIGHTNING_WORK_MODULE_FILE"] == __file__
  
      assert "LIGHTNING_COMPONENT_NAME" not in os.environ
      assert "LIGHTNING_WORK" not in os.environ
      assert "LIGHTNING_WORK_MODULE_FILE" not in os.environ
  
      work.on_exit()
      subprocess_mock.Popen().kill.assert_called_once()
  
file_path: pytorch-lightning/tests/tests_app/components/serve/test_streamlit.py
imports: import os
  import sys
  from unittest import mock
  import lightning.app
  import pytest
  from lightning.app.components.serve.streamlit import ServeStreamlit, _build_model, _PatchedWork
  from lightning_utilities.core.imports import RequirementCache
label_desc: Use image node_id 1 for calling a global function with example usage: test_streamlit_start_stop_server(subprocess_mock) without return types