code: def test_set_locale(lang, enc):
      before_locale = _get_current_locale()
  
      enc = codecs.lookup(enc).name
      new_locale = lang, enc
  
      if not can_set_locale(new_locale):
          msg = "unsupported locale setting"
  
          with pytest.raises(locale.Error, match=msg):
              with set_locale(new_locale):
                  pass
      else:
          with set_locale(new_locale) as normalized_locale:
              new_lang, new_enc = normalized_locale.split(".")
              new_enc = codecs.lookup(enc).name
  
              normalized_locale = new_lang, new_enc
              assert normalized_locale == new_locale
  
      # Once we exit the "with" statement, locale should be back to what it was.
      after_locale = _get_current_locale()
      assert before_locale == after_locale
  
file_path: pandas/pandas/tests/config/test_localization.py
imports: import codecs
  import locale
  import os
  import pytest
  from pandas._config.localization import can_set_locale, get_locales, set_locale
  from pandas.compat import ISMUSL
  import pandas
label_desc: Use image node_id 9 for calling a global function with example usage: test_set_locale(lang, enc) without return types