code: def test_contains(self):
      # GH 17717
      p0 = Period("2017-09-01")
      p1 = Period("2017-09-02")
      p2 = Period("2017-09-03")
      p3 = Period("2017-09-04")
  
      ps0 = [p0, p1, p2]
      idx0 = PeriodIndex(ps0)
  
      for p in ps0:
          assert p in idx0
          assert str(p) in idx0
  
      # GH#31172
      # Higher-resolution period-like are _not_ considered as contained
      key = "2017-09-01 00:00:01"
      assert key not in idx0
      with pytest.raises(KeyError, match=key):
          idx0.get_loc(key)
  
      assert "2017-09" in idx0
  
      assert p3 not in idx0
  
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 TestContains obj's underlying member method code with example usage: obj.test_contains() without return types