code: def test_get_third_party_modules_from_config():
      r = get_third_party_modules_from_config({}, NodeRole.SUPERVISOR)
      assert r == []
  
      r = get_third_party_modules_from_config({}, NodeRole.WORKER)
      assert r == []
  
      config = {"third_party_modules": {"supervisor": ["a.module"]}}
      r = get_third_party_modules_from_config(
          config, NodeRole.SUPERVISOR
      )
      assert r == ["a.module"]
      r = get_third_party_modules_from_config(config, NodeRole.WORKER)
      assert r == []
  
      config = {"third_party_modules": {"worker": ["b.module"]}}
      r = get_third_party_modules_from_config(config, NodeRole.WORKER)
      assert r == ["b.module"]
      r = get_third_party_modules_from_config(
          config, NodeRole.SUPERVISOR
      )
      assert r == []
  
      config = {"third_party_modules": ["ab.module"]}
      r = get_third_party_modules_from_config(
          config, NodeRole.SUPERVISOR
      )
      assert r == ["ab.module"]
      r = get_third_party_modules_from_config(config, NodeRole.WORKER)
      assert r == ["ab.module"]
  
      os.environ["MARS_LOAD_MODULES"] = "c.module,d.module"
      try:
          r = get_third_party_modules_from_config(
              config, NodeRole.SUPERVISOR
          )
          assert r == ["ab.module", "c.module", "d.module"]
          r = get_third_party_modules_from_config(
              config, NodeRole.WORKER
          )
          assert r == ["ab.module", "c.module", "d.module"]
          r = get_third_party_modules_from_config(
              {}, NodeRole.SUPERVISOR
          )
          assert r == ["c.module", "d.module"]
          r = get_third_party_modules_from_config({}, NodeRole.WORKER)
          assert r == ["c.module", "d.module"]
      finally:
          os.environ.pop("MARS_LOAD_MODULES", None)
  
      config = {"third_party_modules": "ab.module"}
      with pytest.raises(TypeError, match="str"):
          get_third_party_modules_from_config(
              config, NodeRole.SUPERVISOR
          )
      config = {"third_party_modules": {"supervisor": "a.module"}}
      with pytest.raises(TypeError, match="str"):
          get_third_party_modules_from_config(
              config, NodeRole.SUPERVISOR
          )
  
imports: import os
  import pytest
  from ...services import NodeRole
  from ..utils import load_service_config_file, get_third_party_modules_from_config, next_in_thread
label_desc: Use image node_id 2 for calling a global function with example usage: test_get_third_party_modules_from_config() without return types