code: def test_generate_requirements_txt_no_currently_used_packages(
      monkeypatch,
  ):
      with patch("cloudpickle.load"), patch("tqdm.tqdm"), patch(
          "sagemaker.serve.detector.pickle_dependencies.subprocess.run"
      ) as subprocess_run, patch(
          "sagemaker.serve.detector.pickle_dependencies.subprocess.Popen"
      ) as subprocess_popen, patch(
          "builtins.open"
      ) as mocked_open, monkeypatch.context() as m:
          mock_run_stdout = MagicMock()
          mock_run_stdout.stdout = json.dumps([]).encode("utf-8")
          subprocess_run.return_value = mock_run_stdout
  
          mock_popen_stdout = MagicMock()
          mock_popen_stdout.stdout = []
          subprocess_popen.return_value = mock_popen_stdout
  
          m.setattr(sys, "modules", CURRENTLY_USED_FILES)
  
          open_dest_file = mock_open()
          mocked_open.side_effect = [
              mock_open().return_value,
              open_dest_file.return_value,
          ]
  
          get_requirements_for_pkl_file(
              "/path/to/serve.pkl", "path/to/requirements.txt"
          )
  
          mocked_open.assert_any_call("/path/to/serve.pkl", mode="rb")
          mocked_open.assert_any_call(
              "path/to/requirements.txt", mode="w+"
          )
  
          assert 2 == subprocess_run.call_count
          subprocess_run_call = call(
              EXPECTED_SUBPROCESS_CMD + ["list", "--format", "json"],
              stdout=subprocess.PIPE,
              check=True,
          )
          subprocess_run.assert_has_calls(
              [subprocess_run_call, subprocess_run_call]
          )
  
          assert 0 == subprocess_popen.call_count
  
          mocked_writes = open_dest_file.return_value.__enter__().write
  
          assert 0 == mocked_writes.call_count
  
file_path: sagemaker-python-sdk/tests/unit/sagemaker/serve/detector/test_pickle_dependencies.py
imports: from __future__ import absolute_import
  from sagemaker.serve.detector.pickle_dependencies import get_requirements_for_pkl_file
  import boto3
  import json
  import io
  import sys
  import subprocess
  from mock import MagicMock, mock_open, patch, call
  from types import ModuleType
  import logging
label_desc: Use image node_id 4 for calling a global function with example usage: test_generate_requirements_txt_no_currently_used_packages(monkeypatch) without return types