code: def test_get_loc_msg(self):
      idx = period_range("2000-1-1", freq="Y", periods=10)
      bad_period = Period("2012", "Y")
      with pytest.raises(
          KeyError, match=r"^Period\('2012', 'Y-DEC'\)$"
      ):
          idx.get_loc(bad_period)
  
      try:
          idx.get_loc(bad_period)
      except KeyError as inst:
          assert inst.args[0] == bad_period
  
imports: from datetime import datetime
  import re
  import numpy
  import pytest
  from pandas._libs.tslibs import period
  from pandas.errors import InvalidIndexError
  import pandas
  from pandas import DatetimeIndex, NaT, Period, PeriodIndex, Series, Timedelta, date_range, notna, period_range
  import pandas._testing
label_desc: Use image node_id 1 for calling the TestGetLoc obj's underlying member method code with example usage: obj.test_get_loc_msg() without return types